From 9a9c48e382927e9968c3a477d462cc385f419d4e Mon Sep 17 00:00:00 2001 From: aniampio Date: Fri, 24 Nov 2023 14:54:06 +0000 Subject: [PATCH] Add docs --- .../src/scheme/setup.rs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/common/nym_offline_compact_ecash/src/scheme/setup.rs b/common/nym_offline_compact_ecash/src/scheme/setup.rs index e9a385650a..2f1a566737 100644 --- a/common/nym_offline_compact_ecash/src/scheme/setup.rs +++ b/common/nym_offline_compact_ecash/src/scheme/setup.rs @@ -323,6 +323,7 @@ pub fn aggregate_indices_signatures( "Not enough unique indices shares".to_string(), )); } + // Evaluate at 0 the Lagrange basis polynomials k_i let coefficients = generate_lagrangian_coefficients_at_origin( &signatures @@ -434,6 +435,37 @@ mod tests { .is_ok()); } + #[test] + fn test_sign_coins_fail() { + let L = 32; + let params = setup(L); + let authorities_keypairs = ttp_keygen(¶ms.grp(), 2, 3).unwrap(); + let indices: [u64; 3] = [1, 2, 3]; + + // Pick one authority to do the signing + let sk_0_auth = authorities_keypairs[0].secret_key(); + let vk_1_auth = authorities_keypairs[1].verification_key(); + + // list of verification keys of each authority + let verification_keys_auth: Vec = authorities_keypairs + .iter() + .map(|keypair| keypair.verification_key()) + .collect(); + // the global master verification key + let verification_key = + aggregate_verification_keys(&verification_keys_auth, Some(&indices)).unwrap(); + + let partial_signatures = sign_coin_indices(¶ms, &verification_key, &sk_0_auth); + // Since we used a non matching verification key to verify the signature, the verification should fail + assert!(verify_coin_indices_signatures( + ¶ms, + &verification_key, + &vk_1_auth, + &partial_signatures + ) + .is_err()); + } + #[test] fn test_aggregate_coin_signatures() { let L = 32;