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

chore: Add hash_to_field Noir alternative #3338

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

kevaundray
Copy link
Contributor

Description

Related to noir-lang/acvm#358

This only adds a test to show that we can implement the hash_to_field blackbox function in Noir.

Since hash_to_field takes Field elements as parameters, the decomposition shown is needed to hash a ~254 bit element instead of a single u8.

Problem*

Resolves

Summary*

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [Exceptional Case] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@kevaundray kevaundray marked this pull request as ready for review October 29, 2023 16:25
@github-actions
Copy link
Contributor

github-actions bot commented Oct 29, 2023

Changes to circuit sizes

Generated at commit: 284ed3304027a3a216b5231bcec512c08dca3549, compared to commit: 4e2d35f256bea2fee3a6cbd7af0c0c15a37c0a2e

🧾 Summary (10% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
hash_to_field +228 ❌ +22800.00% +2,016 ❌ +10.38%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
hash_to_field 229 (+228) +22800.00% 21,444 (+2,016) +10.38%

@kevaundray
Copy link
Contributor Author

kevaundray commented Oct 29, 2023

I think a 10% slowdown is okay in exchange for one less ACIR opcode and we can optimize bytes32_to_field in the future by finding out the diff between the Noir algorithm and the bb algorithm.

EDIT: My mistake, the benchmark is 10% more because we modified the tests

@kevaundray kevaundray added this pull request to the merge queue Oct 30, 2023
@kevaundray kevaundray removed this pull request from the merge queue due to a manual request Oct 30, 2023
@kevaundray kevaundray enabled auto-merge October 30, 2023 12:13
@TomAFrench
Copy link
Member

I think a 10% slowdown is okay in exchange for one less ACIR opcode and we can optimize bytes32_to_field in the future by finding out the diff between the Noir algorithm and the bb algorithm.

Most likely due to it using a slice for the byte decomposition. This adds a bunch of costs when it comes to turning it back into a [u8; 32]

@kevaundray kevaundray added this pull request to the merge queue Oct 30, 2023
Merged via the queue into master with commit 93d41e1 Oct 30, 2023
29 checks passed
@kevaundray kevaundray deleted the kw/start-deprecating-hash-to-field branch October 30, 2023 13:16
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.

3 participants