Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error assert(remainder == [0; N]); #36

Closed
olehmisar opened this issue Dec 6, 2024 · 6 comments
Closed

Error assert(remainder == [0; N]); #36

olehmisar opened this issue Dec 6, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@olehmisar
Copy link

olehmisar commented Dec 6, 2024

Aim

Crashes in runtime when trying to verify a signature. Worked fine in Noir v0.34.0 and noir_rsa v0.3.1

Expected Behavior

Verifies the signature successfully

Bug

Fails with error

error: Failed to solve program: 'Failed to solve brillig function'
   ┌─ /Users/oleh/nargo/github.com/noir-lang/noir-bignumv0.4.2/src/fns/expressions.nr:74:12
   │
74 │     assert(remainder == [0; N]);
   │            -------------------
   │
   = Call stack:
     1. src/lib.nr:150:13
     2. src/lib.nr:35:18
     3. /Users/oleh/nargo/github.com/noir-lang/noir_rsa/v0.4.1/lib/src/rsa.nr:58:29
     4. /Users/oleh/nargo/github.com/noir-lang/noir-bignumv0.4.2/src/runtime_bignum.nr:421:23
     5. /Users/oleh/nargo/github.com/noir-lang/noir-bignumv0.4.2/src/fns/constrained_ops.nr:401:5
     6. /Users/oleh/nargo/github.com/noir-lang/noir-bignumv0.4.2/src/fns/expressions.nr:279:9
     7. /Users/oleh/nargo/github.com/noir-lang/noir-bignumv0.4.2/src/fns/expressions.nr:74:12

The remainder is:

[0xa57d16eb98c6dd795d331e0affb9e6, 0x81cc1e1e6ca115ced7ebeb7844f7a9, 0x3320372c3d55c139d74c0bc4f2b2c8, 0xb7cf2ab68856be87f1bb17e8e22ae3, 0x47ca0c105b0fe86ef8753b073ad390, 0xa3ac5611108c1a33b9982ea7794fa1, 0xd03621f194f9fd0405b90019730ba1, 0x6ee056ff08bc31d7457cce66659217, 0xea66ea9b44c2df580ebb4ed1f866f7, 0xf1d3bc63178fd1ff64b5ceec0013a5, 0x22671fbf2a2df0a7ea5b628d082634, 0x23c73fe567a86ce063a6df42c3a2e9, 0x2d43dbcf26d2d99c187d359ac374fa, 0x9bafeffe923c3b34ead4222c0171ac, 0x222a03ea3a686b0d3a1dbac7236030, 0xae42007b32610f974c85b402161959, 0x59603a5fe6a8159b68674f86b3bd5b, 0x066bae339a6679b5bc25625192e851]

To Reproduce

  1. git clone https://github.com/olehmisar/zklogin.git
  2. git checkout noir-1
  3. cd packages/evm-contracts/noir
  4. noirup -v 1.0.0-beta.0
  5. nargo test

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

Blocker

Blocker Context

Can't update zklogin to the latest version of Noir. Currently stuck at 0.34.0

Nargo Version

1.0.0-beta.0

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@olehmisar olehmisar added the bug Something isn't working label Dec 6, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Dec 6, 2024
@TomAFrench
Copy link
Member

Have you tested this on the latest nightly version of noir?

@olehmisar
Copy link
Author

No. But I am sure it’s rsa lib issue and not noir issue

@olehmisar
Copy link
Author

@TomAFrench tested with Noir nightly-2024-12-07. Same error:

error: Failed to solve program: 'Failed to solve brillig function'
   ┌─ /Users/oleh/nargo/github.com/noir-lang/noir-bignum/v0.4.2/src/fns/expressions.nr:74:12
   │
74 │     assert(remainder == [0; N]);
   │            -------------------
   │
   = Call stack:
     1. src/lib.nr:150:13
     2. src/lib.nr:35:18
     3. /Users/oleh/nargo/github.com/noir-lang/noir_rsa/v0.4.1/lib/src/rsa.nr:58:29
     4. /Users/oleh/nargo/github.com/noir-lang/noir-bignum/v0.4.2/src/runtime_bignum.nr:421:23
     5. /Users/oleh/nargo/github.com/noir-lang/noir-bignum/v0.4.2/src/fns/constrained_ops.nr:401:5
     6. /Users/oleh/nargo/github.com/noir-lang/noir-bignum/v0.4.2/src/fns/expressions.nr:279:9
     7. /Users/oleh/nargo/github.com/noir-lang/noir-bignum/v0.4.2/src/fns/expressions.nr:74:12

[jwt] Testing tests::test_jwt_payload... ok
[jwt] 1 test passed, 1 test failed

@TomAFrench
Copy link
Member

@kashbrti I remember this line causing issues earlier which you fixed (something in the barrett reduction I think). Can you take a look to see if there's still an issue here.

@olehmisar
Copy link
Author

I got info from @madztheo that I should regenerate modulus and redc params because they were changed in bignum 0.4.0. Let me try and get back to you if it fixed the error

@olehmisar
Copy link
Author

yeah, it was incorrect computation of modulus and redc params inside js

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants