Skip to content

Commit

Permalink
anemoi: added the number of rounds for each instance and for each cur…
Browse files Browse the repository at this point in the history
…ve inside the parameters class; modified the SAGE script accordingly
  • Loading branch information
Vesselin Velichkov committed Jan 27, 2023
1 parent bb7fee5 commit ac0e770
Show file tree
Hide file tree
Showing 9 changed files with 510 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ namespace libsnark
/// - quad_exponent : quadratic exponent applied in the mappings Q_gamma,
/// Q_delta. Note that quad_exponent=2 for prime fields and
/// quad_exponent=3 for binary fields
/// - nrounds128 : array of total number of rounds for instances with
/// different number of columns e.g. 1,2,3,4 and 128-bit
/// security
/// - nrounds256 : array of total number of rounds for instances with
/// different number of columns e.g. 1,2,3,4 and 256-bit
/// security
/// - C_constants_col_"num_cols", D_constants_col_"num_cols" : the C
/// and D round constants of the Anemoi
/// permutation for a state with 1,2,3 or 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public:
static constexpr size_t quad_exponent = 2;
static const BignumT alpha_inv;
static const BignumT delta;
static const std::vector<size_t> nrounds128;
static const std::vector<size_t> nrounds256;
static const std::vector<std::vector<BignumT>> C_constants_col_one;
static const std::vector<std::vector<BignumT>> D_constants_col_one;
static const std::vector<std::vector<BignumT>> C_constants_col_two;
Expand All @@ -39,6 +41,11 @@ public:
static const std::vector<std::vector<BignumT>> D_constants_col_four;
};

const std::vector<size_t> anemoi_parameters<libff::alt_bn128_pp>::nrounds128 = {
19, 12, 10, 10};
const std::vector<size_t> anemoi_parameters<libff::alt_bn128_pp>::nrounds256 = {
35, 20, 15, 14};

const anemoi_parameters<libff::alt_bn128_pp>::BignumT
anemoi_parameters<libff::alt_bn128_pp>::alpha_inv =
anemoi_parameters<libff::alt_bn128_pp>::BignumT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public:
static constexpr size_t quad_exponent = 2;
static const BignumT alpha_inv;
static const BignumT delta;
static const std::vector<size_t> nrounds128;
static const std::vector<size_t> nrounds256;
static const std::vector<std::vector<BignumT>> C_constants_col_one;
static const std::vector<std::vector<BignumT>> D_constants_col_one;
static const std::vector<std::vector<BignumT>> C_constants_col_two;
Expand All @@ -39,6 +41,11 @@ public:
static const std::vector<std::vector<BignumT>> D_constants_col_four;
};

const std::vector<size_t> anemoi_parameters<libff::bls12_377_pp>::nrounds128 = {
18, 11, 10, 10};
const std::vector<size_t> anemoi_parameters<libff::bls12_377_pp>::nrounds256 = {
34, 19, 15, 13};

const anemoi_parameters<libff::bls12_377_pp>::BignumT
anemoi_parameters<libff::bls12_377_pp>::alpha_inv =
anemoi_parameters<libff::bls12_377_pp>::BignumT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public:
static constexpr size_t quad_exponent = 2;
static const BignumT alpha_inv;
static const BignumT delta;
static const std::vector<size_t> nrounds128;
static const std::vector<size_t> nrounds256;
static const std::vector<std::vector<BignumT>> C_constants_col_one;
static const std::vector<std::vector<BignumT>> D_constants_col_one;
static const std::vector<std::vector<BignumT>> C_constants_col_two;
Expand All @@ -40,6 +42,11 @@ public:
static const std::vector<std::vector<BignumT>> D_constants_col_four;
};

const std::vector<size_t> anemoi_parameters<libff::bls12_381_pp>::nrounds128 = {
19, 12, 10, 10};
const std::vector<size_t> anemoi_parameters<libff::bls12_381_pp>::nrounds256 = {
35, 20, 15, 14};

const anemoi_parameters<libff::bls12_381_pp>::BignumT
anemoi_parameters<libff::bls12_381_pp>::alpha_inv =
anemoi_parameters<libff::bls12_381_pp>::BignumT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public:
static constexpr size_t quad_exponent = 2;
static const BignumT alpha_inv;
static const BignumT delta;
static const std::vector<size_t> nrounds128;
static const std::vector<size_t> nrounds256;
static const std::vector<std::vector<BignumT>> C_constants_col_one;
static const std::vector<std::vector<BignumT>> D_constants_col_one;
static const std::vector<std::vector<BignumT>> C_constants_col_two;
Expand All @@ -39,6 +41,11 @@ public:
static const std::vector<std::vector<BignumT>> D_constants_col_four;
};

const std::vector<size_t> anemoi_parameters<libff::bn128_pp>::nrounds128 = {
19, 12, 10, 10};
const std::vector<size_t> anemoi_parameters<libff::bn128_pp>::nrounds256 = {
35, 20, 15, 14};

const anemoi_parameters<libff::bn128_pp>::BignumT
anemoi_parameters<libff::bn128_pp>::alpha_inv =
anemoi_parameters<libff::bn128_pp>::BignumT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public:
static constexpr size_t quad_exponent = 2;
static const BignumT alpha_inv;
static const BignumT delta;
static const std::vector<size_t> nrounds128;
static const std::vector<size_t> nrounds256;
static const std::vector<std::vector<BignumT>> C_constants_col_one;
static const std::vector<std::vector<BignumT>> D_constants_col_one;
static const std::vector<std::vector<BignumT>> C_constants_col_two;
Expand All @@ -39,6 +41,11 @@ public:
static const std::vector<std::vector<BignumT>> D_constants_col_four;
};

const std::vector<size_t> anemoi_parameters<libff::bw6_761_pp>::nrounds128 = {
19, 12, 10, 10};
const std::vector<size_t> anemoi_parameters<libff::bw6_761_pp>::nrounds256 = {
35, 20, 15, 14};

const anemoi_parameters<libff::bw6_761_pp>::BignumT
anemoi_parameters<libff::bw6_761_pp>::alpha_inv =
anemoi_parameters<libff::bw6_761_pp>::BignumT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public:
static constexpr size_t quad_exponent = 2;
static const BignumT alpha_inv;
static const BignumT delta;
static const std::vector<size_t> nrounds128;
static const std::vector<size_t> nrounds256;
static const std::vector<std::vector<BignumT>> C_constants_col_one;
static const std::vector<std::vector<BignumT>> D_constants_col_one;
static const std::vector<std::vector<BignumT>> C_constants_col_two;
Expand All @@ -39,6 +41,11 @@ public:
static const std::vector<std::vector<BignumT>> D_constants_col_four;
};

const std::vector<size_t> anemoi_parameters<libff::mnt4_pp>::nrounds128 = {
19, 12, 10, 10};
const std::vector<size_t> anemoi_parameters<libff::mnt4_pp>::nrounds256 = {
35, 20, 15, 14};

const anemoi_parameters<libff::mnt4_pp>::BignumT
anemoi_parameters<libff::mnt4_pp>::alpha_inv =
anemoi_parameters<libff::mnt4_pp>::BignumT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public:
static constexpr size_t quad_exponent = 2;
static const BignumT alpha_inv;
static const BignumT delta;
static const std::vector<size_t> nrounds128;
static const std::vector<size_t> nrounds256;
static const std::vector<std::vector<BignumT>> C_constants_col_one;
static const std::vector<std::vector<BignumT>> D_constants_col_one;
static const std::vector<std::vector<BignumT>> C_constants_col_two;
Expand All @@ -39,6 +41,11 @@ public:
static const std::vector<std::vector<BignumT>> D_constants_col_four;
};

const std::vector<size_t> anemoi_parameters<libff::mnt6_pp>::nrounds128 = {
18, 11, 10, 10};
const std::vector<size_t> anemoi_parameters<libff::mnt6_pp>::nrounds256 = {
34, 19, 15, 13};

const anemoi_parameters<libff::mnt6_pp>::BignumT
anemoi_parameters<libff::mnt6_pp>::alpha_inv =
anemoi_parameters<libff::mnt6_pp>::BignumT(
Expand Down
Loading

0 comments on commit ac0e770

Please sign in to comment.