-
Notifications
You must be signed in to change notification settings - Fork 1
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
[BASE] Anemoi hash r1cs #65
base: develop
Are you sure you want to change the base?
Conversation
This PR includes all the plonk changes, so it's almost impossible to review. |
Done. This branch now points to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good firs attempt. You've got the constraints being formed correctly. I think there are a couple of optimizations to do here, and these simple examples are great to use to discuss that. Also some intermediate values can potentially be removed.
Let's discuss this on a call.
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, functionally this looks correct. I think we can improve the clarity a bit.
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.tcc
Outdated
Show resolved
Hide resolved
f0e4a56
to
18a7e49
Compare
void generate_r1cs_constraints(); | ||
void generate_r1cs_witness(); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion for how to reuse the gadget
class anemoi_power_two_round_1_gadget : public anemoi_power_two_gadget
{
anemoi_power_two_round_1_gadget(
rotoboard<FieldT> &pb,
const pb_variable<FieldT> &input,
const pb_variable<FieldT> &output,
const std::string &annotation_prefix = "")
: anemoi_power_two_gadget(..., ...ALPHA, ... BETA, ...)
{
}
}
class anemoi_power_two_round_2_gadget : public anemoi_power_two_gadget
{
anemoi_power_two_round_2_gadget(
rotoboard<FieldT> &pb,
const pb_variable<FieldT> &input,
const pb_variable<FieldT> &output,
const std::string &annotation_prefix = "")
: anemoi_power_two_gadget(..., anemoi_constants_selector<ppT>::BETA, ... anemoi_constants_selector<ppT>::GAMMA, ...)
{
}
}
3a52056
to
88ce670
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick intermediate review.
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/anemoi_components.hpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/tests/test_anemoi_gadget.cpp
Outdated
Show resolved
Hide resolved
libsnark/gadgetlib1/gadgets/hashes/anemoi/tests/test_anemoi_gadget.cpp
Outdated
Show resolved
Hide resolved
135a0d1
to
d93aa48
Compare
9d20eef
to
96c4c2a
Compare
fc83681
to
c2584b2
Compare
…f type const in several classes. resp. added their initialization in the initialization list of the constructor (cf. #65 (comment))
…me and binary fields (#77, #65 (comment), #65 (comment)) - resolved conflicts after rebase onto anemoi-hash-r1cs
… allowed dimension (addresses #77 , #65 (comment)) - fixed conflicts after rebase onto anemoi-hash-r1cs
…mbs> with anemoi_parameters<libff::bls12_381_pp>::BignumT for improved readability (#101 (comment))
…-round Anemoi hash r1cs permutation round
…me and binary fields (#77, #65 (comment), #65 (comment)) - resolved conflicts after rebase onto anemoi-hash-r1cs
…ent number of columns using class specialization (#102 (comment))
…ter from all anemoi_permutation_mds::permutation_mds functions (#102 (comment))
…_mds::permutation_mds after rebase onto anemoi-hash-r1cs
…umns Anemoi hash r1cs numstatecolumns
… of interest, namely Mnt4, Mnt6, BW6_761, BN128, ALT_BN128, BLS12_377, BLS12_381 (#82)
…st_for_curve (#106 (comment)); removed template specialization for test_intermediate_gadgets_bls12_381 (#106 (comment)).
Anemoi: parameters struct for all curves of interest
…ve inside the parameters class; modified the SAGE script accordingly
…est_anemoi_round_prime_field_gadget
…ield_gadget class. it is used to extract the round constants C,D, which arenow removed from the class. removed two unused functions from the same class.
…tput number of r1cs constraints and variables
…ounds Anemoi circuit to run all rounds
Related to Issue #54. See also https://eprint.iacr.org/2022/840 for details.
This PR and branch are the destination for future anemoi-related changes.