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

[BASE] Anemoi hash r1cs #65

Open
wants to merge 120 commits into
base: develop
Choose a base branch
from
Open

[BASE] Anemoi hash r1cs #65

wants to merge 120 commits into from

Conversation

vesselinux
Copy link
Collaborator

@vesselinux vesselinux commented Jul 29, 2022

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.

@vesselinux vesselinux requested a review from dtebbs July 29, 2022 08:07
@dtebbs
Copy link
Contributor

dtebbs commented Jul 29, 2022

This PR includes all the plonk changes, so it's almost impossible to review.
Could you poinit it at the relevant branch so I can take a look at this.

@vesselinux vesselinux changed the base branch from develop to plonk July 29, 2022 13:32
@vesselinux
Copy link
Collaborator Author

This PR includes all the plonk changes, so it's almost impossible to review. Could you poinit it at the relevant branch so I can take a look at this.

Done. This branch now points to plonk which is the correct branch it is based on. Sorry!

Copy link
Contributor

@dtebbs dtebbs left a 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.

Copy link
Contributor

@dtebbs dtebbs left a 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.

void generate_r1cs_constraints();
void generate_r1cs_witness();
};

Copy link
Contributor

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, ...)
  {
  }
}

Copy link
Contributor

@dtebbs dtebbs left a 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/pb_variable.tcc Outdated Show resolved Hide resolved
libsnark/gadgetlib1/pb_variable.tcc Outdated Show resolved Hide resolved
libsnark/gadgetlib1/protoboard.tcc Outdated Show resolved Hide resolved
@vesselinux vesselinux force-pushed the anemoi-hash-r1cs branch 2 times, most recently from 9d20eef to 96c4c2a Compare October 21, 2022 21:47
vesselinux pushed a commit that referenced this pull request Oct 31, 2022
…f type const in several classes. resp. added their initialization in the initialization list of the constructor (cf. #65 (comment))
vesselinux pushed a commit that referenced this pull request Jan 12, 2023
…me and binary fields (#77, #65 (comment), #65 (comment)) - resolved conflicts after rebase onto anemoi-hash-r1cs
vesselinux pushed a commit that referenced this pull request Jan 12, 2023
… allowed dimension (addresses #77 , #65 (comment)) - fixed conflicts after rebase onto anemoi-hash-r1cs
Vesselin Velichkov and others added 24 commits January 13, 2023 16:18
…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
… 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
…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
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.

2 participants