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

Action circuit #101

Merged
merged 49 commits into from
Jul 27, 2021
Merged

Action circuit #101

merged 49 commits into from
Jul 27, 2021

Conversation

therealyingtong
Copy link
Contributor

@therealyingtong therealyingtong commented Jun 4, 2021

Closes #4. Closes #157. Closes #153.

Canonicity checks for Sinsemilla inputs documented at #134.

@therealyingtong therealyingtong force-pushed the action-circuit branch 2 times, most recently from 6b443de to 6bde1a7 Compare June 4, 2021 09:23
@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2021

Codecov Report

Merging #101 (3f506a0) into main (bd28b46) will decrease coverage by 0.23%.
The diff coverage is 84.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     zcash/orchard#101      +/-   ##
==========================================
- Coverage   87.36%   87.13%   -0.24%     
==========================================
  Files          62       63       +1     
  Lines        6294     7922    +1628     
==========================================
+ Hits         5499     6903    +1404     
- Misses        795     1019     +224     
Impacted Files Coverage Δ
src/circuit/gadget/ecc/chip/mul/overflow.rs 81.81% <ø> (ø)
src/constants.rs 100.00% <ø> (ø)
...rc/circuit/gadget/sinsemilla/chip/hash_to_point.rs 78.97% <55.55%> (-1.13%) ⬇️
src/circuit/gadget/ecc/chip/mul.rs 85.65% <80.00%> (+1.20%) ⬆️
src/circuit/gadget/sinsemilla/commit_ivk.rs 80.59% <80.59%> (ø)
src/circuit/gadget/sinsemilla/note_commit.rs 81.06% <81.06%> (ø)
src/circuit/gadget/sinsemilla/merkle.rs 91.74% <83.33%> (-2.12%) ⬇️
src/circuit.rs 87.08% <86.78%> (-1.81%) ⬇️
src/tree.rs 81.94% <87.50%> (+3.22%) ⬆️
src/circuit/gadget/sinsemilla.rs 87.77% <88.00%> (+3.11%) ⬆️
... and 39 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd28b46...3f506a0. Read the comment docs.

@therealyingtong therealyingtong force-pushed the action-circuit branch 2 times, most recently from d74bf7c to 73dd71f Compare June 4, 2021 17:06
@therealyingtong therealyingtong changed the base branch from base-action-circuit to merkle-chip June 4, 2021 17:07
@therealyingtong therealyingtong force-pushed the merkle-chip branch 3 times, most recently from 8a5f541 to 527963c Compare June 5, 2021 09:05
@therealyingtong therealyingtong force-pushed the action-circuit branch 2 times, most recently from 303f6cc to 645cab3 Compare June 5, 2021 13:43
@therealyingtong therealyingtong force-pushed the merkle-chip branch 2 times, most recently from 2731554 to 8602455 Compare June 6, 2021 12:13
@therealyingtong therealyingtong force-pushed the merkle-chip branch 2 times, most recently from 63ecab5 to 6d71190 Compare June 6, 2021 16:51
src/circuit.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

Flushing comments.

src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
let s = meta.query_selector(selector);
// Addition of two field elements poseidon_hash(nk, rho_old) + psi_old.
let q_add = meta.selector();
meta.create_gate("poseidon_hash(nk, rho_old) + psi_old", |meta| {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could merge this into the same gate as q_orchard.

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 for the QEDIT review.

I want to go back and do a more thorough review of the canonicity checks, but that shouldn't block merging.

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

One blocking comment, otherwise utACK with various comments and suggestions.

src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
let k_3 = meta.query_advice(advices[5], Rotation::cur());

// j = LSB + (2)k_0 + (2^10)k_1
let j = meta.query_advice(advices[0], Rotation::next());
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that we need to witness j in this region (even though it could be computed here), because we need a cell for this intermediate result that we can constrain to be the input to the decomposition.

src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
src/circuit.rs Outdated Show resolved Hide resolved
therealyingtong and others added 2 commits July 27, 2021 12:49
Instead of separately witnessing k_1 and equating it to z1_j, we
can directly make use of z1_j in the gate. This allows us to fit
the region into a 5 x 2 area, improving the layout.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
By rearranging the pieces in the gate, we remove a prev() query and
preserve proximity between pieces involved in the same constraint.

This commit also includes several minor fixes:
- use strict mode for decomposition of j in y-coordinate check;
- Name All Polynomial Constraints;
- remove point_repr() helper function;
- variable renaming and docfixes.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK modulo test fixes. Circuit layout LGTM.

action-circuit-layout

src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
src/circuit/gadget/sinsemilla/note_commit.rs Outdated Show resolved Hide resolved
@str4d str4d marked this pull request as ready for review July 27, 2021 08:48
@str4d str4d merged commit bb90f2e into main Jul 27, 2021
@str4d str4d deleted the action-circuit branch July 27, 2021 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants