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

Upgrade Dangling witness Handling #320

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/benches/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use noah_accumulators::merkle_tree::{PersistentMerkleTree, Proof, TreePath};
use noah_algebra::bn254::{BN254PairingEngine, BN254Scalar};
use noah_algebra::prelude::*;
use noah_crypto::anemoi_jive::{
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, JiveTrace, ANEMOI_JIVE_BN254_SALTS,
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, JiveTrace, ANEMOI_JIVE_BN254_SALTS, N_ANEMOI_ROUNDS,
};
use noah_plonk::plonk::constraint_system::{TurboCS, VarIndex};
use noah_plonk::plonk::indexer::indexer;
Expand Down Expand Up @@ -129,8 +129,8 @@ pub fn compute_merkle_root_variables_2_20(
cs: &mut TurboPlonkCS,
elem: AccElemVars,
path_vars: &MerklePathVars,
leaf_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
traces: &Vec<JiveTrace<BN254Scalar, 2, 14>>,
leaf_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
traces: &Vec<JiveTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>>,
) -> VarIndex {
let (uid, commitment) = (elem.uid, elem.commitment);

Expand Down
32 changes: 17 additions & 15 deletions api/src/anon_xfr/abar_to_abar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use merlin::Transcript;
use noah_algebra::bn254::BN254Scalar;
use noah_algebra::prelude::*;
use noah_crypto::anemoi_jive::{
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, ANEMOI_JIVE_BN254_SALTS,
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, ANEMOI_JIVE_BN254_SALTS, N_ANEMOI_ROUNDS,
};
use noah_plonk::plonk::{
constraint_system::{TurboCS, VarIndex},
Expand Down Expand Up @@ -67,11 +67,11 @@ pub struct AXfrPreNote {
/// Witness.
pub witness: AXfrWitness,
/// The traces of the input commitments.
pub input_commitments_traces: Vec<AnemoiVLHTrace<BN254Scalar, 2, 14>>,
pub input_commitments_traces: Vec<AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>>,
/// The traces of the output commitments.
pub output_commitments_traces: Vec<AnemoiVLHTrace<BN254Scalar, 2, 14>>,
pub output_commitments_traces: Vec<AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>>,
/// The traces of the nullifiers.
pub nullifiers_traces: Vec<AnemoiVLHTrace<BN254Scalar, 2, 14>>,
pub nullifiers_traces: Vec<AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>>,
/// Input key pair.
pub input_keypair: KeyPair,
}
Expand Down Expand Up @@ -177,7 +177,7 @@ pub fn init_anon_xfr_note(
.map(|output| output.owner_memo.clone().ok_or(NoahError::ParameterError))
.collect();

let output_commitments_traces: Vec<AnemoiVLHTrace<BN254Scalar, 2, 14>> = outputs
let output_commitments_traces: Vec<AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>> = outputs
.iter()
.map(|output| {
let (_, commitment_trace) = commit(
Expand Down Expand Up @@ -430,9 +430,9 @@ pub(crate) fn prove_xfr<R: CryptoRng + RngCore>(
rng: &mut R,
params: &ProverParams,
secret_inputs: &AXfrWitness,
nullifiers_traces: &[AnemoiVLHTrace<BN254Scalar, 2, 14>],
input_commitments_traces: &[AnemoiVLHTrace<BN254Scalar, 2, 14>],
output_commitments_traces: &[AnemoiVLHTrace<BN254Scalar, 2, 14>],
nullifiers_traces: &[AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>],
input_commitments_traces: &[AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>],
output_commitments_traces: &[AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>],
folding_witness: &AXfrAddressFoldingWitness,
) -> Result<AXfrPlonkPf> {
let mut transcript = Transcript::new(ANON_XFR_PLONK_PROOF_TRANSCRIPT);
Expand Down Expand Up @@ -627,9 +627,9 @@ impl AXfrPubInputs {
pub(crate) fn build_multi_xfr_cs(
witness: &AXfrWitness,
fee_type: BN254Scalar,
nullifiers_traces: &[AnemoiVLHTrace<BN254Scalar, 2, 14>],
input_commitments_traces: &[AnemoiVLHTrace<BN254Scalar, 2, 14>],
output_commitments_traces: &[AnemoiVLHTrace<BN254Scalar, 2, 14>],
nullifiers_traces: &[AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>],
input_commitments_traces: &[AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>],
output_commitments_traces: &[AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>],
folding_witness: &AXfrAddressFoldingWitness,
) -> (TurboPlonkCS, usize) {
assert_ne!(witness.payers_witnesses.len(), 0);
Expand Down Expand Up @@ -1112,7 +1112,7 @@ mod tests {
use merlin::Transcript;
use noah_algebra::{bn254::BN254Scalar, prelude::*};
use noah_crypto::anemoi_jive::{
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, ANEMOI_JIVE_BN254_SALTS,
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, ANEMOI_JIVE_BN254_SALTS, N_ANEMOI_ROUNDS,
};
use noah_plonk::plonk::constraint_system::{TurboCS, VarIndex};
use sha2::Sha512;
Expand Down Expand Up @@ -2182,8 +2182,9 @@ mod tests {
)
.unwrap();

let mut nullifiers_traces = Vec::<AnemoiVLHTrace<BN254Scalar, 2, 14>>::new();
let mut input_commitments_traces = Vec::<AnemoiVLHTrace<BN254Scalar, 2, 14>>::new();
let mut nullifiers_traces = Vec::<AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>>::new();
let mut input_commitments_traces =
Vec::<AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>>::new();
for payer_witness in secret_inputs.payers_witnesses.iter() {
let (_, nullifier_trace) = nullify(
&payer_witness.secret_key.clone().into_keypair(),
Expand All @@ -2204,7 +2205,8 @@ mod tests {
input_commitments_traces.push(input_commitment_trace);
}

let mut output_commitments_traces = Vec::<AnemoiVLHTrace<BN254Scalar, 2, 14>>::new();
let mut output_commitments_traces =
Vec::<AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>>::new();
for payee_witness in secret_inputs.payees_witnesses.iter() {
let (_, output_commitment_trace) = commit(
&payee_witness.public_key,
Expand Down
14 changes: 7 additions & 7 deletions api/src/anon_xfr/abar_to_ar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use digest::{consts::U64, Digest};
use merlin::Transcript;
use noah_algebra::{bn254::BN254Scalar, prelude::*, ristretto::PedersenCommitmentRistretto};
use noah_crypto::anemoi_jive::{
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, ANEMOI_JIVE_BN254_SALTS,
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, ANEMOI_JIVE_BN254_SALTS, N_ANEMOI_ROUNDS,
};
use noah_plonk::plonk::{
constraint_system::{TurboCS, VarIndex},
Expand Down Expand Up @@ -61,9 +61,9 @@ pub struct AbarToArPreNote {
/// Witness.
pub witness: PayerWitness,
/// The trace of the input commitment.
pub input_commitment_trace: AnemoiVLHTrace<BN254Scalar, 2, 14>,
pub input_commitment_trace: AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
/// The trace of the nullifier.
pub nullifier_trace: AnemoiVLHTrace<BN254Scalar, 2, 14>,
pub nullifier_trace: AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
/// Input key pair.
pub input_keypair: KeyPair,
}
Expand Down Expand Up @@ -340,8 +340,8 @@ fn prove_abar_to_ar<R: CryptoRng + RngCore>(
rng: &mut R,
params: &ProverParams,
payers_witness: &PayerWitness,
nullifier_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
input_commitment_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
nullifier_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
input_commitment_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
folding_witness: &AXfrAddressFoldingWitness,
) -> Result<AXfrPlonkPf> {
let mut transcript = Transcript::new(ABAR_TO_AR_PLONK_PROOF_TRANSCRIPT);
Expand All @@ -368,8 +368,8 @@ fn prove_abar_to_ar<R: CryptoRng + RngCore>(
/// Construct the anonymous-to-transparent constraint system.
pub fn build_abar_to_ar_cs(
payer_witness: &PayerWitness,
nullifier_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
input_commitment_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
nullifier_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
input_commitment_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
folding_witness: &AXfrAddressFoldingWitness,
) -> (TurboPlonkCS, usize) {
let mut cs = TurboCS::new();
Expand Down
14 changes: 7 additions & 7 deletions api/src/anon_xfr/abar_to_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use noah_algebra::{
traits::PedersenCommitment,
};
use noah_crypto::anemoi_jive::{
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, ANEMOI_JIVE_BN254_SALTS,
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, ANEMOI_JIVE_BN254_SALTS, N_ANEMOI_ROUNDS,
};
use noah_crypto::{
delegated_schnorr::{prove_delegated_schnorr, verify_delegated_schnorr, DSInspection, DSProof},
Expand Down Expand Up @@ -69,9 +69,9 @@ pub struct AbarToBarPreNote {
/// Witness.
pub witness: PayerWitness,
/// The trace of the input commitment.
pub input_commitment_trace: AnemoiVLHTrace<BN254Scalar, 2, 14>,
pub input_commitment_trace: AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
/// The trace of the nullifier.
pub nullifier_trace: AnemoiVLHTrace<BN254Scalar, 2, 14>,
pub nullifier_trace: AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
/// Input key pair.
pub input_keypair: KeyPair,
/// Inspection data in the delegated Schnorr proof on Ristretto.
Expand Down Expand Up @@ -536,8 +536,8 @@ fn prove_abar_to_bar<R: CryptoRng + RngCore>(
rng: &mut R,
params: &ProverParams,
payers_witness: &PayerWitness,
nullifier_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
input_commitment_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
nullifier_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
input_commitment_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
proof: &DSProof<BN254Scalar, RistrettoScalar, RistrettoPoint>,
inspection: &DSInspection<BN254Scalar, RistrettoScalar, RistrettoPoint>,
beta: &RistrettoScalar,
Expand Down Expand Up @@ -572,8 +572,8 @@ fn prove_abar_to_bar<R: CryptoRng + RngCore>(
/// Construct the anonymous-to-confidential constraint system.
pub fn build_abar_to_bar_cs(
payer_witness: &PayerWitness,
nullifier_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
input_commitment_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
nullifier_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
input_commitment_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
proof: &DSProof<BN254Scalar, RistrettoScalar, RistrettoPoint>,
inspection: &DSInspection<BN254Scalar, RistrettoScalar, RistrettoPoint>,
beta: &RistrettoScalar,
Expand Down
4 changes: 2 additions & 2 deletions api/src/anon_xfr/ar_to_abar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::parameters::params::VerifierParams;
use crate::xfr::structs::{BlindAssetRecord, OpenAssetRecord};
use merlin::Transcript;
use noah_algebra::{bn254::BN254Scalar, prelude::*};
use noah_crypto::anemoi_jive::{AnemoiJive254, AnemoiVLHTrace};
use noah_crypto::anemoi_jive::{AnemoiJive254, AnemoiVLHTrace, N_ANEMOI_ROUNDS};
use noah_plonk::plonk::{
constraint_system::TurboCS, prover::prover_with_lagrange, verifier::verifier,
};
Expand Down Expand Up @@ -189,7 +189,7 @@ pub fn verify_ar_to_abar_body(params: &VerifierParams, body: &ArToAbarBody) -> R
/// Construct the transparent-to-anonymous constraint system.
pub fn build_ar_to_abar_cs(
payee_data: PayeeWitness,
output_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
output_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
) -> (TurboPlonkCS, usize) {
let mut cs = TurboCS::new();
cs.load_anemoi_jive_parameters::<AnemoiJive254>();
Expand Down
6 changes: 3 additions & 3 deletions api/src/anon_xfr/bar_to_abar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use noah_algebra::{
ristretto::{PedersenCommitmentRistretto, RistrettoPoint, RistrettoScalar},
traits::PedersenCommitment,
};
use noah_crypto::anemoi_jive::{AnemoiJive, AnemoiJive254, AnemoiVLHTrace};
use noah_crypto::anemoi_jive::{AnemoiJive, AnemoiJive254, AnemoiVLHTrace, N_ANEMOI_ROUNDS};
use noah_crypto::{
delegated_schnorr::{prove_delegated_schnorr, verify_delegated_schnorr, DSInspection, DSProof},
field_simulation::{SimFr, SimFrParams, SimFrParamsBN254Ristretto},
Expand Down Expand Up @@ -303,7 +303,7 @@ pub(crate) fn prove_bar_to_abar_cs<R: CryptoRng + RngCore>(
inspection: &DSInspection<BN254Scalar, RistrettoScalar, RistrettoPoint>,
beta: &RistrettoScalar,
lambda: &RistrettoScalar,
comm_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
comm_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
) -> Result<AXfrPlonkPf> {
let mut transcript = Transcript::new(BAR_TO_ABAR_PLONK_PROOF_TRANSCRIPT);
let (mut cs, _) = build_bar_to_abar_cs(
Expand Down Expand Up @@ -387,7 +387,7 @@ pub(crate) fn build_bar_to_abar_cs(
non_zk_state: &DSInspection<BN254Scalar, RistrettoScalar, RistrettoPoint>,
beta: &RistrettoScalar,
lambda: &RistrettoScalar,
comm_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
comm_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
) -> (TurboPlonkCS, usize) {
let mut cs = TurboCS::new();
cs.load_anemoi_jive_parameters::<AnemoiJive254>();
Expand Down
14 changes: 7 additions & 7 deletions api/src/anon_xfr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use noah_algebra::{
prelude::*,
};
use noah_crypto::anemoi_jive::{
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, JiveTrace, ANEMOI_JIVE_BN254_SALTS,
AnemoiJive, AnemoiJive254, AnemoiVLHTrace, JiveTrace, ANEMOI_JIVE_BN254_SALTS, N_ANEMOI_ROUNDS,
};
use noah_plonk::{
plonk::{
Expand Down Expand Up @@ -236,7 +236,7 @@ pub fn nullify(
amount: u64,
asset_type_scalar: BN254Scalar,
uid: u64,
) -> Result<(BN254Scalar, AnemoiVLHTrace<BN254Scalar, 2, 14>)> {
) -> Result<(BN254Scalar, AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>)> {
let pub_key = key_pair.get_pk();

let pow_2_64 = BN254Scalar::from(u64::MAX).add(&BN254Scalar::from(1u32));
Expand Down Expand Up @@ -282,7 +282,7 @@ pub fn commit_in_cs(
asset_var: VarIndex,
public_key_type_var: VarIndex,
public_key_scalars: &[VarIndex; 3],
trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
) -> VarIndex {
let output_var = cs.new_variable(trace.output);
let zero_var = cs.zero_var();
Expand Down Expand Up @@ -310,7 +310,7 @@ pub fn commit(
blind: BN254Scalar,
amount: u64,
asset_type_scalar: BN254Scalar,
) -> Result<(Commitment, AnemoiVLHTrace<BN254Scalar, 2, 14>)> {
) -> Result<(Commitment, AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>)> {
let address_format_number: BN254Scalar = match public_key.0 {
PublicKeyInner::Ed25519(_) => BN254Scalar::one(),
PublicKeyInner::Secp256k1(_) => BN254Scalar::zero(),
Expand Down Expand Up @@ -344,7 +344,7 @@ pub(crate) fn nullify_in_cs(
asset_type: VarIndex,
secret_key_type: VarIndex,
public_key_scalars: &[VarIndex; 3],
trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
) -> VarIndex {
let output_var = cs.new_variable(trace.output);
let zero_var = cs.zero_var();
Expand Down Expand Up @@ -467,8 +467,8 @@ pub fn compute_merkle_root_variables(
cs: &mut TurboPlonkCS,
elem: AccElemVars,
path_vars: &MerklePathVars,
leaf_trace: &AnemoiVLHTrace<BN254Scalar, 2, 14>,
traces: &[JiveTrace<BN254Scalar, 2, 14>],
leaf_trace: &AnemoiVLHTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>,
traces: &[JiveTrace<BN254Scalar, 2, N_ANEMOI_ROUNDS>],
) -> VarIndex {
let (uid, commitment) = (elem.uid, elem.commitment);

Expand Down
12 changes: 7 additions & 5 deletions crypto/src/anemoi_jive/bls12_381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ use noah_algebra::bls12_381::BLSScalar;
use noah_algebra::new_bls12_381_fr;
use noah_algebra::prelude::*;

use super::N_ANEMOI_ROUNDS;

/// The structure that stores the parameters for the Anemoi-Jive hash function for BLS12-381.
pub struct AnemoiJive381;

impl AnemoiJive<BLSScalar, 2usize, 14usize> for AnemoiJive381 {
impl AnemoiJive<BLSScalar, 2usize, N_ANEMOI_ROUNDS> for AnemoiJive381 {
const ALPHA: u32 = 5u32;
const GENERATOR: BLSScalar = new_bls12_381_fr!("7");
const GENERATOR_INV: BLSScalar = new_bls12_381_fr!(
"14981678621464625851270783002338847382197300714436467949315331057125308909861"
);
const GENERATOR_SQUARE_PLUS_ONE: BLSScalar = new_bls12_381_fr!("50");
const ROUND_KEYS_X: [[BLSScalar; 2usize]; 14usize] = [
const ROUND_KEYS_X: [[BLSScalar; 2usize]; N_ANEMOI_ROUNDS] = [
[
new_bls12_381_fr!("39"),
new_bls12_381_fr!(
Expand Down Expand Up @@ -125,7 +127,7 @@ impl AnemoiJive<BLSScalar, 2usize, 14usize> for AnemoiJive381 {
),
],
];
const ROUND_KEYS_Y: [[BLSScalar; 2usize]; 14usize] = [
const ROUND_KEYS_Y: [[BLSScalar; 2usize]; N_ANEMOI_ROUNDS] = [
[
new_bls12_381_fr!(
"14981678621464625851270783002338847382197300714436467949315331057125308909900"
Expand Down Expand Up @@ -239,7 +241,7 @@ impl AnemoiJive<BLSScalar, 2usize, 14usize> for AnemoiJive381 {
),
],
];
const PREPROCESSED_ROUND_KEYS_X: [[BLSScalar; 2usize]; 14usize] = [
const PREPROCESSED_ROUND_KEYS_X: [[BLSScalar; 2usize]; N_ANEMOI_ROUNDS] = [
[
new_bls12_381_fr!(
"35132796657602600463082375807523947538812231901617345651700352053179413136781"
Expand Down Expand Up @@ -353,7 +355,7 @@ impl AnemoiJive<BLSScalar, 2usize, 14usize> for AnemoiJive381 {
),
],
];
const PREPROCESSED_ROUND_KEYS_Y: [[BLSScalar; 2usize]; 14usize] = [
const PREPROCESSED_ROUND_KEYS_Y: [[BLSScalar; 2usize]; N_ANEMOI_ROUNDS] = [
[
new_bls12_381_fr!(
"15708940413097757154186986844111910752060195475863555301496544479594607502297"
Expand Down
11 changes: 6 additions & 5 deletions crypto/src/anemoi_jive/bn254.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use super::N_ANEMOI_ROUNDS;
use crate::anemoi_jive::AnemoiJive;
use noah_algebra::bn254::BN254Scalar;
use noah_algebra::new_bn254_fr;

/// The structure that stores the parameters for the Anemoi-Jive hash function for BN254.
pub struct AnemoiJive254;

impl AnemoiJive<BN254Scalar, 2usize, 14usize> for AnemoiJive254 {
impl AnemoiJive<BN254Scalar, 2usize, N_ANEMOI_ROUNDS> for AnemoiJive254 {
const ALPHA: u32 = 5u32;
const GENERATOR: BN254Scalar = new_bn254_fr!("5");
const GENERATOR_INV: BN254Scalar = new_bn254_fr!(
"8755297148735710088898562298102910035419345760166413737479281674630323398247"
);
const GENERATOR_SQUARE_PLUS_ONE: BN254Scalar = new_bn254_fr!("26");
const ROUND_KEYS_X: [[BN254Scalar; 2]; 14] = [
const ROUND_KEYS_X: [[BN254Scalar; 2]; N_ANEMOI_ROUNDS] = [
[
new_bn254_fr!("37"),
new_bn254_fr!(
Expand Down Expand Up @@ -124,7 +125,7 @@ impl AnemoiJive<BN254Scalar, 2usize, 14usize> for AnemoiJive254 {
),
],
];
const ROUND_KEYS_Y: [[BN254Scalar; 2]; 14] = [
const ROUND_KEYS_Y: [[BN254Scalar; 2]; N_ANEMOI_ROUNDS] = [
[
new_bn254_fr!(
"8755297148735710088898562298102910035419345760166413737479281674630323398284"
Expand Down Expand Up @@ -238,7 +239,7 @@ impl AnemoiJive<BN254Scalar, 2usize, 14usize> for AnemoiJive254 {
),
],
];
const PREPROCESSED_ROUND_KEYS_X: [[BN254Scalar; 2]; 14] = [
const PREPROCESSED_ROUND_KEYS_X: [[BN254Scalar; 2]; N_ANEMOI_ROUNDS] = [
[
new_bn254_fr!(
"9875235397644879082677551174832367614794066768374461301425281161472772669364"
Expand Down Expand Up @@ -352,7 +353,7 @@ impl AnemoiJive<BN254Scalar, 2usize, 14usize> for AnemoiJive254 {
),
],
];
const PREPROCESSED_ROUND_KEYS_Y: [[BN254Scalar; 2]; 14] = [
const PREPROCESSED_ROUND_KEYS_Y: [[BN254Scalar; 2]; N_ANEMOI_ROUNDS] = [
[
new_bn254_fr!(
"13004335645468876947782817511996516830557692388848756239167689579223703209154"
Expand Down
Loading