Skip to content

Add ZSA features#845

Merged
daira merged 14 commits intozcash:mainfrom
QED-it:zsa1
Aug 6, 2025
Merged

Add ZSA features#845
daira merged 14 commits intozcash:mainfrom
QED-it:zsa1

Conversation

@ConstanceBeguier
Copy link
Contributor

This PR contains the following modifications that are required for ZSA:

  • Add a new LookupRangeCheck config named LookupRangeCheck4_5BConfig optimized for 4, 5 and 10-bit range checks
  • Add variable-base sign-scalar multiplication function called mul_sign
  • Add mux functionalities into CondSwapChip
  • Update SinsemillaChip to support evaluating a hash from a private point
  • Extend SinsemillaChip with functions that allow separate evaluation of the hash and blinding factor of a commitment
  • Standardize test circuit names with My...Circuit convention

YaoJGalteland and others added 12 commits August 8, 2024 14:54
This commit contains the following modifications:
- Add tests for Lookup, ECC, Merkle, and Sinsemilla to verify that the verification key and the proof have not been modified by comparing them to those saved in a file.
- Introduce a `LookupRangeCheck` trait that provides common methods for a lookup range check.
- Use this new trait as a generic parameter in configs, chips and tests that are using lookup.
- Create a new Lookup chip which is optimized for 4, 5 and 10-bit range check and add tests for this new chip.
- Add `init_from_private_point` parameter in `SinsemillaConfig`. If this parameter is set to false, the `SinsemillaChip` is the same as the current `SinsemillaChip` used in vanilla circuit. Otherwise, the `SinsemillaChip` is modified to support hash from private point.

---------

Co-authored-by: YaoGalteland <yao@qed-it.com>
Co-authored-by: Dmitry Demin <dmitry@qed-it.com>
Co-authored-by: Constance Beguier <constance@qed-it.com>
- Move lookup table `load` function into `LookupRangeCheck` trait (and remove `table_range_check_tag` function which is no longer used)
- Move some imports to reduce the diff with the main branch
- Standardize test circuit names with `My...Circuit` convention
- Reduce visibility of some functions
- Update changelog file
…okup table (#43)

This PR adds a comment to clarify why a duplicated-rows range check lookup table was chosen.
Comment on lines +116 to +120
/// If init_from_private_point is set,
/// | offset | x_A | x_P | q_sinsemilla4 |
/// --------------------------------------
/// | 0 | | y_Q | |
/// | 1 | x_Q | | 1 |
Copy link
Contributor

@daira daira Jul 29, 2025

Choose a reason for hiding this comment

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

This should be documented in book/src/design/gadgets/sinsemilla.md. I have a commit for that and will push it later.

Copy link
Contributor

@daira daira Jul 29, 2025

Choose a reason for hiding this comment

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

I have not checked any of these binary files, but they are only used for tests and I assume they correspond to the original proofs.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have not checked any of these pinned verification keys.

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK with suggestions.

Co-authored-by: Daira-Emma Hopwood <daira@jacaranda.org>
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 65.04298% with 122 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.67%. Comparing base (bb56139) to head (27b2b33).
⚠️ Report is 1510 commits behind head on main.

Files with missing lines Patch % Lines
halo2_gadgets/src/utilities/lookup_range_check.rs 77.65% 40 Missing ⚠️
halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs 25.00% 27 Missing ⚠️
halo2_gadgets/src/ecc/chip/witness_point.rs 0.00% 12 Missing ⚠️
halo2_gadgets/src/sinsemilla.rs 0.00% 10 Missing ⚠️
halo2_gadgets/src/ecc/chip/mul_fixed/short.rs 73.33% 8 Missing ⚠️
halo2_gadgets/src/ecc/chip.rs 40.00% 6 Missing ⚠️
halo2_gadgets/src/sinsemilla/merkle/chip.rs 0.00% 6 Missing ⚠️
halo2_gadgets/src/sinsemilla/chip.rs 44.44% 5 Missing ⚠️
halo2_gadgets/src/utilities/cond_swap.rs 90.24% 4 Missing ⚠️
halo2_gadgets/src/ecc.rs 62.50% 3 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #845      +/-   ##
==========================================
+ Coverage   67.96%   73.67%   +5.70%     
==========================================
  Files          47      105      +58     
  Lines        5891    11951    +6060     
==========================================
+ Hits         4004     8805    +4801     
- Misses       1887     3146    +1259     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK, good to merge.

@daira daira merged commit 2308caf into zcash:main Aug 6, 2025
20 checks passed
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