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

feat: enable to_radix for any field element #1343

Merged
merged 5 commits into from
May 15, 2023
Merged

Conversation

guipublic
Copy link
Contributor

@guipublic guipublic commented May 12, 2023

Related issue(s)

Related to #1129

Description

Summary of changes

Enable to_radix for any field element, a maximum bit size was requested before. Now we compute the first value manually in order to reduce the size by the radix have have it below the maximum.

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.

Additional context

This PR is related to #1313, where the same feature is done in noir.

BEGIN_COMMIT_OVERRIDE
feat: Enable to_radix for any field element (#1343)
END_COMMIT_OVERRIDE

@kevaundray
Copy link
Contributor

Can we have a test for this?

@guipublic
Copy link
Contributor Author

I added one

@kevaundray
Copy link
Contributor

I added one

Perfect!

kevaundray
kevaundray previously approved these changes May 12, 2023
@kevaundray kevaundray self-requested a review May 12, 2023 11:09
Copy link
Contributor

@kevaundray kevaundray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems there is an issue with #1313 (comment) when they were testing your PR -- I can't dig into it right now, can you check to see if the issue is related to this PR or something else?

@guipublic
Copy link
Contributor Author

I checked and I don't think it is related, all the to_bits() in the example lead to the same result with my changes or with the noir version.

@guipublic guipublic added this pull request to the merge queue May 15, 2023
@shuklaayush
Copy link
Contributor

A minimal example that isn't working for me:

main.nr

fn main(x: Field) {
    x.to_le_bits(254);
}

Prover.toml

# The first 254 bit number
x = "0x2000000000000000000000000000000000000000000000000000000000000000"
# All inputs up to 253 bits seem to work
# x = "0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
nargo execute main

@kevaundray kevaundray removed this pull request from the merge queue due to a manual request May 15, 2023
@kevaundray
Copy link
Contributor

@guipublic apologies for removing it from the queue, can you check the above message?

@guipublic
Copy link
Contributor Author

A minimal example that isn't working for me:

Thank you for the example, a range check was incorrect and I fixed it.

@kevaundray kevaundray enabled auto-merge May 15, 2023 17:54
@kevaundray kevaundray added this pull request to the merge queue May 15, 2023
Merged via the queue into master with commit c3bdec2 May 15, 2023
@kevaundray kevaundray deleted the gd/field_radix branch May 15, 2023 18:35
@Savio-Sou
Copy link
Collaborator

Savio-Sou commented May 16, 2023

Does this require any changes to what is currently documented on this page?

@TomAFrench
Copy link
Member

Nope, this shouldn't need any updates to the documentation as it already implies you can do it for all field elements.

TomAFrench added a commit that referenced this pull request May 17, 2023
* master: (66 commits)
  feat(nargo)!: retire print-acir in favour of flag (#1328)
  chore(ssa): enable cse for assert (#1350)
  chore(ssa refactor): Add basic instruction simplification (#1329)
  chore(noir): Release 0.6.0 (#1279)
  feat: enable to_radix for any field element (#1343)
  chore(ssa refactor): Simplify inlining pass and fix inlining failure (#1337)
  chore!: Update to acvm 0.11.0 (#1322)
  feat: Add ECDSA secp256k1 builtin test (#1294)
  chore: add support for encoding/decoding inputs from JSON (#1325)
  feat: Issue an error when attempting to use a `return` expression (#1330)
  chore(ssa refactor): Fix inlining bug (#1335)
  fix: to-bits and to-radix for > 128 bits (#1312)
  chore(parser): Parser error optimisation (#1292)
  chore(ssa refactor): Implement function inlining (#1293)
  chore: fix installation link in readme (#1326)
  chore: fix installation link in readme (#1326)
  feat(stdlib): Add keccak (#1249)
  fix: Parsing nested generics (#1319)
  chore(ssa refactor): Document some SSA-gen functions (#1321)
  fix: Assigning to tuple fields (#1318)
  ...
spalladino pushed a commit to spalladino/noir that referenced this pull request May 24, 2023
* Enable to_radix for any field element

* add integration test

* use proper bound during modulo (and small optimisation)

* update integration test
sirasistant pushed a commit that referenced this pull request May 31, 2023
* feat: enable to_radix for any field element (#1343)

* Enable to_radix for any field element

* add integration test

* use proper bound during modulo (and small optimisation)

* update integration test

* feat: Add ECDSA secp256k1 builtin test (#1294)

* Copy ECDSA from commit 92ef9b4

* rework for new syntax

* commit since github was down

* [NOT MERGEABLE] - Skip all tests except ecdsa

* change parameter order

* update flake.lock

* update test

* update flake.lock

* update flake.lock

* modify test

* add message + hashed_message to program

* remove underscore

* modify input to use low-S

* commit s variant 1

* commit variant S2

* modify s value in signature to value that passes in acvm/pwg

* update flake.lock

* remove if statement to make tests go faster

* cleanup test

---------

Co-authored-by: guipublic <47281315+guipublic@users.noreply.github.com>
Co-authored-by: kevaundray <kevtheappdev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants