From f411ca7cc4a89af9618e908c0b336efe66dd7140 Mon Sep 17 00:00:00 2001 From: driemworks Date: Mon, 28 Oct 2024 13:42:26 -0500 Subject: [PATCH] feat: update tests --- core/src/murmur.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/core/src/murmur.rs b/core/src/murmur.rs index 51d474c..dd2f4db 100644 --- a/core/src/murmur.rs +++ b/core/src/murmur.rs @@ -370,6 +370,7 @@ mod tests { use rand_chacha::ChaCha20Rng; use ark_std::rand::SeedableRng; use ark_serialize::CanonicalDeserialize; + use rand_core::OsRng; /// pub const BLOCK_SCHEDULE: &[BlockNumber] = &[ @@ -580,11 +581,11 @@ mod tests { pos, )); } - + #[test] fn it_can_generate_and_verify_schnorr_proofs() { let mut rng = ChaCha20Rng::seed_from_u64(0); - let keypair = w3f_bls::KeypairVT::::generate(&mut rng); + let keypair = w3f_bls::KeypairVT::::generate(&mut OsRng); let double_public: DoublePublicKey = DoublePublicKey( keypair.into_public_key_in_signature_group().0, keypair.public.0, @@ -613,20 +614,23 @@ mod tests { 0, ).unwrap()); + let mut same_rng = ChaCha20Rng::seed_from_u64(0); let another_murmur_store = MurmurStore::new::( seed.clone(), BLOCK_SCHEDULE.to_vec(), 1, same_double_public, - &mut rng, + &mut same_rng, ).unwrap(); let another_proof = another_murmur_store.proof; let another_pk = another_murmur_store.public_key; + assert!(pk == another_pk); + // now verify the proof for nonce = 1 assert!(verifier::verify_update::( another_proof, - another_pk, + pk, 1, ).unwrap()); } @@ -668,6 +672,18 @@ mod tests { let witness2 = generate_witness(seed, rng); assert_eq!(witness1, witness2, "Witnesses should be identical for the same seed"); + + let secret_key_1 = + SecretKey::<<::SignatureGroup as CurveGroup>::Affine>::from_seed(&witness1); + let pubkey_1 = secret_key_1.as_publickey(); + + + let secret_key_2 = + SecretKey::<<::SignatureGroup as CurveGroup>::Affine>::from_seed(&witness2); + let pubkey_2 = secret_key_2.as_publickey(); + + assert!(pubkey_1 == pubkey_2); + } }