From 1e2923082708ce45c84248f3421f71ede5ac05f1 Mon Sep 17 00:00:00 2001 From: natalie Date: Mon, 4 Dec 2023 19:15:25 +0000 Subject: [PATCH] Create DKG vector tests (#587) * Add DKG vector test for ed25519 (#567) * Add DKG test vectors for all ciphersuites (#567) * Add description for DKG vector test (#567) * Update imports for DKG vector tests (#567) --- frost-core/src/keys/dkg.rs | 2 + frost-core/src/tests.rs | 1 + frost-core/src/tests/vectors_dkg.rs | 222 ++++++++++++++++++ frost-ed25519/tests/helpers/vectors_dkg.json | 55 +++++ frost-ed25519/tests/integration_tests.rs | 8 + frost-ed448/tests/helpers/vectors_dkg.json | 51 ++++ frost-ed448/tests/integration_tests.rs | 8 + frost-p256/tests/helpers/vectors_dkg.json | 51 ++++ frost-p256/tests/integration_tests.rs | 8 + .../tests/helpers/vectors_dkg.json | 51 ++++ frost-ristretto255/tests/integration_tests.rs | 8 + .../tests/helpers/vectors_dkg.json | 51 ++++ frost-secp256k1/tests/integration_tests.rs | 8 + 13 files changed, 524 insertions(+) create mode 100644 frost-core/src/tests/vectors_dkg.rs create mode 100644 frost-ed25519/tests/helpers/vectors_dkg.json create mode 100644 frost-ed448/tests/helpers/vectors_dkg.json create mode 100644 frost-p256/tests/helpers/vectors_dkg.json create mode 100644 frost-ristretto255/tests/helpers/vectors_dkg.json create mode 100644 frost-secp256k1/tests/helpers/vectors_dkg.json diff --git a/frost-core/src/keys/dkg.rs b/frost-core/src/keys/dkg.rs index fda60148..6dc4025a 100644 --- a/frost-core/src/keys/dkg.rs +++ b/frost-core/src/keys/dkg.rs @@ -289,6 +289,7 @@ pub fn part1( // > Every participant P_i computes a public commitment // > C⃗_i = 〈φ_{i0}, ..., φ_{i(t−1)}〉, where φ_{ij} = g^{a_{ij}}, 0 ≤ j ≤ t − 1 let coefficients = generate_coefficients::(min_signers as usize - 1, &mut rng); + let (coefficients, commitment) = generate_secret_polynomial(&secret, max_signers, min_signers, coefficients)?; let proof_of_knowledge = @@ -517,6 +518,7 @@ pub fn part3( signing_share = signing_share + round2_secret_package.secret_share; let signing_share = SigningShare(signing_share); + // Round 2, Step 4 // // > Each P_i calculates their public verification share Y_i = g^{s_i}. diff --git a/frost-core/src/tests.rs b/frost-core/src/tests.rs index 062ca0c4..d2b1b712 100644 --- a/frost-core/src/tests.rs +++ b/frost-core/src/tests.rs @@ -9,4 +9,5 @@ pub mod helpers; pub mod proptests; pub mod repairable; pub mod vectors; +pub mod vectors_dkg; pub mod vss_commitment; diff --git a/frost-core/src/tests/vectors_dkg.rs b/frost-core/src/tests/vectors_dkg.rs new file mode 100644 index 00000000..1b06a21a --- /dev/null +++ b/frost-core/src/tests/vectors_dkg.rs @@ -0,0 +1,222 @@ +//! Helper function for testing with test vectors. +use std::collections::BTreeMap; + +use debugless_unwrap::DebuglessUnwrap; +use hex::{self}; +use serde_json::Value; + +use crate::{ + keys::{ + dkg::{ + part2, part3, round1::Package as Round1Package, round1::SecretPackage, + round2::Package as Round2Package, + }, + generate_secret_polynomial, KeyPackage, PublicKeyPackage, SigningShare, + VerifiableSecretSharingCommitment, VerifyingShare, + }, + Ciphersuite, Field, Group, Header, Identifier, Scalar, Signature, SigningKey, VerifyingKey, +}; + +/// Test vectors for a ciphersuite. +pub struct DKGTestVectors { + secret: SigningKey, + coefficient: Scalar, + round1_packages: BTreeMap, Round1Package>, + round2_packages: BTreeMap, Round2Package>, + public_key_package: PublicKeyPackage, + key_package: KeyPackage, + participant_id: Identifier, +} + +fn json_to_scalar( + vector: &Value, +) -> <::Field as Field>::Serialization { + (hex::decode(vector.as_str().unwrap()).unwrap()) + .try_into() + .debugless_unwrap() +} + +fn json_to_element(vector: &Value) -> ::Serialization { + (hex::decode(vector.as_str().unwrap()).unwrap()) + .try_into() + .debugless_unwrap() +} + +/// Parse test vectors for a given ciphersuite. +#[allow(clippy::type_complexity)] +pub fn parse_test_vectors_dkg(json_vectors: &Value) -> DKGTestVectors { + let inputs = &json_vectors["inputs"]; + let participant = &inputs["1"]; + + let participant_1_id: Identifier = (participant["identifier"].as_u64().unwrap() as u16) + .try_into() + .unwrap(); + let participant_2_id: Identifier = (inputs["2"]["identifier"].as_u64().unwrap() as u16) + .try_into() + .unwrap(); + let participant_3_id: Identifier = (inputs["3"]["identifier"].as_u64().unwrap() as u16) + .try_into() + .unwrap(); + + let mut round1_packages = BTreeMap::new(); + round1_packages.insert(participant_2_id, build_round_1_package(json_vectors, 2)); + round1_packages.insert(participant_3_id, build_round_1_package(json_vectors, 3)); + + let mut round2_packages = BTreeMap::new(); + round2_packages.insert(participant_2_id, build_round_2_package(json_vectors, 2)); + round2_packages.insert(participant_3_id, build_round_2_package(json_vectors, 3)); + + let secret = SigningKey::deserialize(json_to_scalar::(&participant["signing_key"])).unwrap(); + + let coefficient = <::Field as Field>::deserialize(&json_to_scalar::( + &participant["coefficient"], + )) + .unwrap(); + + let public_key_package = build_public_key_package(json_vectors); + + let verifying_share = + VerifyingShare::deserialize(json_to_element::(&participant["verifying_share"])).unwrap(); + + let verifying_key = + VerifyingKey::deserialize(json_to_element::(&inputs["verifying_key"])).unwrap(); + + let signing_share = + SigningShare::deserialize(json_to_scalar::(&participant["signing_share"])).unwrap(); + + let key_package = KeyPackage { + header: Header::default(), + identifier: participant_1_id, + signing_share, + verifying_share, + verifying_key, + min_signers: 2, + }; + + DKGTestVectors { + secret, + coefficient, + round1_packages, + round2_packages, + public_key_package, + key_package, + participant_id: participant_1_id, + } +} + +fn build_round_1_package( + json_vectors: &Value, + participant_num: usize, +) -> Round1Package { + let inputs = &json_vectors["inputs"]; + let participant = &inputs[participant_num.to_string()]; + let vss_commitment = participant["vss_commitments"] + .as_array() + .unwrap() + .iter() + .map(|v| json_to_element::(v)) + .collect(); + + let commitment = VerifiableSecretSharingCommitment::deserialize(vss_commitment).unwrap(); + + let proof_of_knowledge = Signature::deserialize( + C::SignatureSerialization::try_from( + hex::decode(participant["proof_of_knowledge"].as_str().unwrap()).unwrap(), + ) + .debugless_unwrap(), + ) + .unwrap(); + + Round1Package { + header: Header::default(), + commitment, + proof_of_knowledge, + } +} + +fn build_round_2_package( + json_vectors: &Value, + sender_num: usize, +) -> Round2Package { + let inputs = &json_vectors["inputs"]; + + let signing_share = SigningShare::deserialize(json_to_scalar::( + &inputs["1"]["signing_shares"][sender_num.to_string()], + )) + .unwrap(); + + Round2Package { + header: Header::default(), + signing_share, + } +} + +fn build_public_key_package(json_vectors: &Value) -> PublicKeyPackage { + let inputs = &json_vectors["inputs"]; + + let mut verifying_shares = BTreeMap::new(); + + let max_participants = json_vectors["config"]["MAX_PARTICIPANTS"].as_u64().unwrap() as u8; + + for i in 1..=max_participants { + let participant_id: Identifier = (inputs[i.to_string()]["identifier"].as_u64().unwrap() + as u16) + .try_into() + .unwrap(); + let verifying_share = VerifyingShare::deserialize(json_to_element::( + &inputs[i.to_string()]["verifying_share"], + )) + .unwrap(); + verifying_shares.insert(participant_id, verifying_share); + } + + let verifying_key = + VerifyingKey::deserialize(json_to_element::(&inputs["verifying_key"])).unwrap(); + + PublicKeyPackage { + header: Header::default(), + verifying_shares, + verifying_key, + } +} + +/// Test DKG with the given test vectors for a ciphersuite +pub fn check_dkg_keygen(json_vectors: &Value) { + let DKGTestVectors { + secret, + coefficient, + round1_packages, + round2_packages, + public_key_package, + key_package, + participant_id, + } = parse_test_vectors_dkg(json_vectors); + + let min_signers = 2; + let max_signers = 3; + + let (coefficients, commitment) = generate_secret_polynomial( + &secret as &SigningKey, + max_signers, + min_signers, + vec![coefficient], + ) + .unwrap(); + + let round1_secret_package = SecretPackage { + identifier: participant_id, + coefficients, + commitment: commitment.clone(), + min_signers, + max_signers, + }; + + let (round2_secret_package, _round2_packages_1) = + part2(round1_secret_package, &round1_packages).unwrap(); + + let (expected_key_package, expected_public_key_package) = + part3(&round2_secret_package, &round1_packages, &round2_packages).unwrap(); + + assert_eq!(public_key_package, expected_public_key_package); + assert_eq!(key_package, expected_key_package); +} diff --git a/frost-ed25519/tests/helpers/vectors_dkg.json b/frost-ed25519/tests/helpers/vectors_dkg.json new file mode 100644 index 00000000..bcad1c9c --- /dev/null +++ b/frost-ed25519/tests/helpers/vectors_dkg.json @@ -0,0 +1,55 @@ +{ + "config": { + "MAX_PARTICIPANTS": 3, + "MIN_PARTICIPANTS": 2, + "name": "FROST(Ed25519, SHA-512)", + "group": "ed25519", + "hash": "SHA-512" + }, + "inputs": { + "secret": "8a1b0a95ea88ab6d615060fe392709e857edb4fc35b60f24bf7c085653c4b00e", + "verifying_key": "3d9a67b93cec3acad2d32349cf7bdffaa23ae031a81174ddadae1c96bb455f4d", + "1": { + "identifier": 1, + "signing_key": "fc36bff380c95d607cd78080f493dd382df50f7007ec1b150b9bfbd8041fd208", + "coefficient": "2d2c3e2b558e555b1608838e0ded66cd36d8aaa9ed1e39ce8474855d0825b20e", + "vss_commitments": ["db67948a73033b0c886ed757d97352428df05ad5803aff256bc388c9a0772bfe", "6a25b55a80a287826fbc3ef4d978d15f98f4f573f4d96e798a970780c644f14c"], + "proof_of_knowledge": "64c41c1d0417aef33576c23a5150de2921d6249d7086b10012f942405fc08ed51a872dd021db2ac01e9f4182e950324c5f563421bd835f3f514a60c975cab70c", + "secret": "6cf4cfbbad5e277a46bb621bfdf1b0a39e2ea1d4f927ddea58db7368e36b9108", + "signing_shares": { + "2": "ebb85acf4d46173f519a8680eac89f567d3f4a568843b741b251cc2f3d112b05", + "3": "f088e2c4b3a7f81836968c642721031ed8828d2e3d532fecaa85c481e445000c" + }, + "verifying_share": "f6b5e87c902796d8dab6369cbd6d342a32e46c136e9f1f5af2fc385aed804de3", + "signing_share": "2afd4ef9a27f9e636dd627ae56772951b98f929ebaa13b11ede611e82e9baf08" + }, + "2": { + "identifier": 2, + "vss_commitments": ["17194e192408980956a9cfc388d38456b2e9619c42a57196facd7feaf980a3bd", "0b560ce2f1130dc7066fc47f6e3f1858ef553faf6bbc19d3cd2a502052f95ae5"], + "proof_of_knowledge": "4062dc7fc11144e636f4eddd7f2d8d3e02761671ae913674314a12b91f50bf98e9c410d651c45c3a1766c88524fccb7670de191e12686324c59333e74fc93402", + "coefficient": "ad167472cc332ee98237a1018ea89a7e002420f9e5e518995a10298405a5870d", + "signing_key": "2b76dcb99b75fbada4ffdc213b1ae4ec7c1b2a5da25d9ea85741a3ab376ca307", + "secret": "b4570377a521cfe31fe2d6d7d6f70c8e1d9bca6222a4863953a2888bcccc860a", + "signing_shares": { + "1": "7ce74f90f61fe466fcad9757527aeda99aa565c3e2298eb11484069415693606", + "3": "7fde55b354d5d8dddc940fe932de5d1a6110b9bc4edeba2db7b32c34074d3a0a" + }, + "verifying_share": "f326b756ed38b43a94bdac698e044d9e3f3a08a40e7c9d2e5346dd5bfaadf2f5", + "signing_share": "80a16ad6cf78be27995d5e312722ff2d42a5b08380b49dbc2e7e65c124220e0a" + }, + "3": { + "identifier": 3, + "vss_commitments": ["0e9c22b9edbcd06757eee5ba3cfeb74e4fa6470932aa1ab689c86f1fe3dde70c", "0ae6e3e6ff1d612adb5cabb425ee51f2be9952467ce9b6d83095322909a42dd7"], + "proof_of_knowledge": "37df5a836ceaaf9f5e3b9ae6a485bad5c15788f3883386fe43f2921bbe2cb987d23683ca18973065a00d69bbf74f7961889b820e64f98878df7844a4e4785907", + "coefficient": "7c29694bbb90f21c7d9b7a27eab63911898d2b8e118b8b410c2e68b222073a0e", + "signing_key": "61336fd6127a18548f9709e01b64a8214ff561a02bc8a3aa9e575ccfc13ec60d", + "secret": "8d6468a928bc9b0610f2bf879a0f1738f86615460ac72314d49caf9a56452e05", + "signing_shares": { + "1": "bc3f985e314b276a3c192343816d7562d17d106dd048c77f99f88bf11d8ee804", + "2": "6b3e57fab1e74e61aacfd93d4926172a7e878a48540fe97367721e38485b3a00" + }, + "verifying_share": "6bc91a2755902d955ce220ad0df6fbf57162260949d40bcf5a69cfffec9c085a", + "signing_share": "8bd411475cdc423c1ba94cf11b80e776592d5f675419398800d17173d673f40a" + } + } + } diff --git a/frost-ed25519/tests/integration_tests.rs b/frost-ed25519/tests/integration_tests.rs index 26e29f5d..1421079a 100644 --- a/frost-ed25519/tests/integration_tests.rs +++ b/frost-ed25519/tests/integration_tests.rs @@ -170,6 +170,9 @@ lazy_static! { pub static ref VECTORS_BIG_IDENTIFIER: Value = serde_json::from_str(include_str!("../tests/helpers/vectors-big-identifier.json").trim()) .expect("Test vector is valid JSON"); + pub static ref VECTORS_DKG: Value = + serde_json::from_str(include_str!("../tests/helpers/vectors_dkg.json").trim()) + .expect("Test vector is valid JSON"); } #[test] @@ -177,6 +180,11 @@ fn check_sign_with_test_vectors() { frost_core::tests::vectors::check_sign_with_test_vectors::(&VECTORS); } +#[test] +fn check_sign_with_test_vectors_dkg() { + frost_core::tests::vectors_dkg::check_dkg_keygen::(&VECTORS_DKG); +} + #[test] fn check_sign_with_test_vectors_with_big_identifiers() { frost_core::tests::vectors::check_sign_with_test_vectors::( diff --git a/frost-ed448/tests/helpers/vectors_dkg.json b/frost-ed448/tests/helpers/vectors_dkg.json new file mode 100644 index 00000000..a0943e87 --- /dev/null +++ b/frost-ed448/tests/helpers/vectors_dkg.json @@ -0,0 +1,51 @@ +{ + "config": { + "MAX_PARTICIPANTS": 3, + "MIN_PARTICIPANTS": 2, + "name": "FROST(Ed448, SHAKE256)", + "group": "ed448", + "hash": "SHAKE256" + }, + "inputs": { + "verifying_key": "2c73a3b674e283032effc2494341a608145179b229d664a870336a09b433363079a5ad68044eed31c3cc187267fe8216e559e4e4a8b9f49a80", + "1": { + "identifier": 1, + "signing_key": "01cbf4ac6b8ee0d03b799a62b7d7f32f05e2e117e9362f11004071fdb17ee2740206f45c910b4754eb0729e36e657136acfe16ff5abaf13800", + "coefficient": "74d5bf96312d4aaebf4c6a7e4760a50233f3fb0ce76f34df95781cd8a07b1607073cf70d8272f76956c67f6a9d643ba257e280f19754692300", + "vss_commitments": ["2747193abad63b685e15421f8c15c7c98107bf00d447561906a23e595dcba7367b7cf5ec4b7c751ec4f1721be4a1162d906af4c88a74c09b80", "abd8994d10bfb50fbd360b8f0ade24bd5362c12e06aa72ea9b92ab2d497399c78789a0874d3b0bf99a624549cbc7ec5ccaa503f1d80d189880"], + "proof_of_knowledge": "345f573924403f60672d42d2f428959935f2dca278cec91c955d166ab06ca0e7919e311d376f0c5e4e28a5df96dda71d36576fc7d7748b128063d520bd4b3a6ddcdf05bb84c87a83766218067a3ebb85664084a5a8c58d99b073526234be5ec518333f5e8bcc80ed11d563569123f2fd1200", + "signing_shares": { + "2": "e29c8b642abfa741710945aedadf34ac73ef6863c3e56d599cc3c58039d45b7382674cbd2c8e064c8bae33851c9166536181b83fe34ce02200", + "3": "ae2817fbc11b1595e432362f7d40f28953a545f193851d182e5914f4800ccfcc0194d75f170693e2c0b7be169b45e5d890aaac1d55db9f0d00" + }, + "verifying_share": "4f4c185df443f1d836d213469cf7a52d4e0d0b9dd34046af1c29d0f6b5c7e9a8881c1a138b1c5cdce1a33c42b8f8068aac788f91e7de69a080", + "signing_share": "1fdca64c6411f60ea7e3f4a271d3e625dffcdf1b945b51d98c8dd3500edb23bc8d3d0f885712d8ec8d349be9c3a0f804f60cfd4d2b37db0c00" + }, + "2": { + "identifier": 2, + "signing_key": "9e17dfce20dfd4f0d0bd893a75cba3ff3ab6574d716cd68b4b393d9cd3ff747dcbb6d629ee48d8cc06b29397f3706e18a497f641ee633b2d00", + "coefficient": "37ca04419ca24b74f5da8001d8d6fdcdc86fe7c49b54e6913aae526165d4e6f5b6b075933e452e7f84fc9fed2820f83abde9c1fdf4e8a43500", + "vss_commitments": ["01f375709143c4ad10db96da820082e5c2d802bd0ba78712bdbbe915f1b1d30d20732067395f157c124e4c9e32e37c47a59452950751d7d180", "f410470bc15065f35168c120b784d57db922c047f290ba7c1322b2c713d6d6cc44272b17c6ddc25abe54f4d2acd6c17fccbd9c25595d4ccf00"], + "proof_of_knowledge": "7bd1f9052217b2a02f4798906480ac288927c54dbd846e5bcbf4d08389a205269bf620a6ad1a04a3a0bcfd238c57f5f3960dd4795cebe66a80ed3c4617d163ec19648bd55d2f7acb4c4080c0062b878086ddb73f83aee1ad73426cab8a7d08f4540ccf6e31e08606861dd5daca506fc10d00", + "signing_shares": { + "1": "f6301c2f3c26fc096683a9d1d3d5d113db9103836d3b490b420de030f4750f83107ee27895f03528989428b8a92ee87a5bc318e28a63c43f00", + "3": "cdc0200642d408d6a2147eebba853b2ee42730d85ca72287b5e0ec8182ccbeddcf3e7845cd35588bd9b7c63d9657f704fc706d7becb3d62200" + }, + "verifying_share": "053898556feae3f11a5977bcc0e14eb55086ff935aa22ec2c97b166e97c7a58fc165210d442069e66c4785fd6e7b3e7fcb7dd434055a1e5c80", + "signing_share": "f6ce1c841fd7064fc55d62515c8d6679dbabd725966622f5fa17519b16eb10ca19d51c0fcef9c27e81f7c26885373e0e769f009b4f4d203b00" + }, + "3": { + "identifier": 3, + "signing_key": "82d5659bd4259a777be0b300b2bd1507535931b9143f676d90f505e37e4cdfbb33e9367a61d6cd39a8b7b6ef9f33d3ac25e4ebbfbd02693800", + "coefficient": "1f98090b80b8f340bee147bc3d4549a49082eae6c821056f8787d88d01c0ef10ceaaa0e5b52fc5a818000827fb11122c6bc6c05d97d8361500", + "vss_commitments": ["792df7d8f5569fb6ded2e5db245f2c1f07469d9cb0a7685a027b5d12142d245d1a417cca43ddaeab39f4cf4299aed16c638fc639eae1881000", "f13a1e5fb94aef454a6062735cfde4b37e173b695f3c86b77e5bda60b0a75a0f13446dfeb1fabb515cfb6cfef0973421fbf76bcec44fda9080"], + "proof_of_knowledge": "eb47491f2461792114d357d02102c1a806451cfa88f1297f7a671a87a04de0ffde478ec1c2b91e743379254fe84eb2e0d170c69aec88bc1980bf8009ffc93d6ee0c3713681aa303cf85595bd975953318ab07be9e56dc6ba22465793ee337e383562fafc7525c05b36732b93f5f4fee22300", + "signing_shares": { + "1": "77c1831adb90cd94d0404ec2a8730af57d4e29e10ad02e26ee61328c95f1258a17bad98617632d92ee5aa8224793231db3a599d322b82d2300", + "2": "e29c8b642abfa741710945aedadf34ac73ef6863c3e56d599cc3c58039d45b7382674cbd2c8e064c8bae33851c9166536181b83fe34ce02200" + }, + "verifying_share": "3a1b5a9945fc64b088174c34e16dbced81f824fe8f9f12d1ec98afd4ea593a6ec75a74f70b77522c66681bd468080b525963dbcc2785d53a00", + "signing_share": "da7c3a1048da9e6b8e480a72d48479ab4724f9804e96a44c7f7e04691ffbfdd7a56c2a9644e1ad1075baeae746ce8317f63104e87363652900" + } + } + } diff --git a/frost-ed448/tests/integration_tests.rs b/frost-ed448/tests/integration_tests.rs index 0047c264..3409a7e0 100644 --- a/frost-ed448/tests/integration_tests.rs +++ b/frost-ed448/tests/integration_tests.rs @@ -170,6 +170,9 @@ lazy_static! { pub static ref VECTORS_BIG_IDENTIFIER: Value = serde_json::from_str(include_str!("../tests/helpers/vectors-big-identifier.json").trim()) .expect("Test vector is valid JSON"); + pub static ref VECTORS_DKG: Value = + serde_json::from_str(include_str!("../tests/helpers/vectors_dkg.json").trim()) + .expect("Test vector is valid JSON"); } #[test] @@ -177,6 +180,11 @@ fn check_sign_with_test_vectors() { frost_core::tests::vectors::check_sign_with_test_vectors::(&VECTORS); } +#[test] +fn check_sign_with_test_vectors_dkg() { + frost_core::tests::vectors_dkg::check_dkg_keygen::(&VECTORS_DKG); +} + #[test] fn check_sign_with_test_vectors_with_big_identifiers() { frost_core::tests::vectors::check_sign_with_test_vectors::( diff --git a/frost-p256/tests/helpers/vectors_dkg.json b/frost-p256/tests/helpers/vectors_dkg.json new file mode 100644 index 00000000..c012f770 --- /dev/null +++ b/frost-p256/tests/helpers/vectors_dkg.json @@ -0,0 +1,51 @@ +{ + "config": { + "MAX_PARTICIPANTS": 3, + "MIN_PARTICIPANTS": 2, + "name": "FROST(P-256, SHA-256)", + "group": "P-256", + "hash": "SHA-256" + }, + "inputs": { + "verifying_key": "03639d2ad039e39ae2d7f9a28955a55061d76f0e7b518476c5e5ffa33d1bb9fdb3", + "1": { + "identifier": 1, + "signing_key": "32feae119a184fda4be258289dbce37b1811500600d4e8e9497f0fbd136d052e", + "coefficient": "416eb3b9040da27d2ad3dd812982f9f6da30da9309ae2fcb859fda9f7dcde0e6", + "vss_commitments": ["02a67c8f918d275e9d56108e5eeca8de70b21bdfe4d61d9785b0535d69c52d3f6c", "03e9140b2bcf116755a3397cfc2b3b7bd09a54e3b3544cd81f7e62eb3cc872143a"], + "proof_of_knowledge": "03f77e767e8245f49231442f16b3a7198a1140fac2777d38a6a453a9cc3bca82bb4ef8bc7a32d2d80c275862059fe13a29461c4d2abb3f9c4ae5e718eba907372a", + "signing_shares": { + "2": "a3405e99a61c369a98df1107cd4bd26906e2c55997ad060ca7e7a7744585a03a", + "3": "aea6852c4fe45e87c03a5f2d7b29c7872026cd0e3ca919f324d131564eaf303f" + }, + "verifying_share": "036b59b8128e00afa2a334b19d075695a5c79e59d28dfbaa7945b1520f45edfc52", + "signing_share": "c654459194268778cfcfa5df0fb577625c64c25337c19a2fa81df864290c913c" + }, + "2": { + "identifier": 2, + "signing_key": "ace068a672458c645a313b57f0eb33b160281a9d458df65f6da9a83c078dfb7b", + "coefficient": "f65ff5f233d6aa373eadd5afdc609eb763a1a569f936ae322df7c9fb3a5aca10", + "vss_commitments": ["037ef641c6fe1f49b9940d06a453bf7b3c230713e5ffe7a2e2a4bb373ddba074ef", "0384662ca5e0da725028206063e9226b28a535645ca4d7024284813b1dc9d91abb"], + "proof_of_knowledge": "02c1b8317d76016aeed7300b39c945fd6130f1cef4a3c72ca1fb93a60f54f683a93f6593b42facb608c001d760e84f3bef7066a082f3482386a7ee66d441723ada", + "signing_shares": { + "1": "b5dc1583a23394d4a18a132af0c2d768cc73052c1431488054bec4fc0f08c6fa", + "3": "7ef45ddf14f100f50e6e198b118743392078ab353cfea5d4698a38ff33d490d8" + }, + "verifying_share": "02f928ad1fd3679fd5e73b39e6233068451411dfbb52d4f465c18a176f6be49ce1", + "signing_share": "ce70c7f0911776998785136dabf68bc2dda225c993e46589acb4d9e4c9f7777a" + }, + "3": { + "identifier": 3, + "signing_key": "de58ac798ad7bc1a7206a4cfe4cc4bd51fd4eee73c538e11e01829ad6989cfa6", + "coefficient": "d04dd8b1c50ca26e4e33ba5d965d7bb1bd38d8d4a76d2a663872d26be18885ea", + "vss_commitments": ["0363edc1382241228fc6925dc1789737beec5baae430acc6a113581507fac5cf0e", "03156aff5630761ef046d82a52a813b9043653551636774691590bfedab18efef7"], + "proof_of_knowledge": "024c4d52fe40b0b9cea36d842f91fb244a9c09a96954aedb1ffce08a55296d1b4e09225ae0807611f173821e7c15e2ed7c7d0fa26e5fda5d283e2c96f832df906a", + "signing_shares": { + "1": "f74ac93ca6413751cc5df0ac1a45d15fa6a3dfbf1ddf784bda5e9f9b8cd6a7e0", + "2": "90004a800dc98b07163abc67860d0fd854581ad23beb25671c63a5e4c174e9b8" + }, + "verifying_share": "028e818f24bcadbb04f60c352a9cbe25568a737279cc6db3a91857ab7c992a1aad", + "signing_share": "d68d4a4f8e0865ba3f3a80fc4837a0235edf893ff00730e3b14bbb656ae25db8" + } + } + } diff --git a/frost-p256/tests/integration_tests.rs b/frost-p256/tests/integration_tests.rs index 00022cd5..f2573353 100644 --- a/frost-p256/tests/integration_tests.rs +++ b/frost-p256/tests/integration_tests.rs @@ -170,6 +170,9 @@ lazy_static! { pub static ref VECTORS_BIG_IDENTIFIER: Value = serde_json::from_str(include_str!("../tests/helpers/vectors-big-identifier.json").trim()) .expect("Test vector is valid JSON"); + pub static ref VECTORS_DKG: Value = + serde_json::from_str(include_str!("../tests/helpers/vectors_dkg.json").trim()) + .expect("Test vector is valid JSON"); } #[test] @@ -177,6 +180,11 @@ fn check_sign_with_test_vectors() { frost_core::tests::vectors::check_sign_with_test_vectors::(&VECTORS); } +#[test] +fn check_sign_with_test_vectors_dkg() { + frost_core::tests::vectors_dkg::check_dkg_keygen::(&VECTORS_DKG); +} + #[test] fn check_sign_with_test_vectors_with_big_identifiers() { frost_core::tests::vectors::check_sign_with_test_vectors::(&VECTORS_BIG_IDENTIFIER); diff --git a/frost-ristretto255/tests/helpers/vectors_dkg.json b/frost-ristretto255/tests/helpers/vectors_dkg.json new file mode 100644 index 00000000..abcbc4ca --- /dev/null +++ b/frost-ristretto255/tests/helpers/vectors_dkg.json @@ -0,0 +1,51 @@ +{ + "config": { + "MAX_PARTICIPANTS": 3, + "MIN_PARTICIPANTS": 2, + "name": "FROST(Ed25519, SHA-512)", + "group": "ed25519", + "hash": "SHA-512" + }, + "inputs": { + "verifying_key": "b83aed2f02a94ddd7f2b08543fb45f372aac439fc6001b91d8ddac25f1ce953c", + "1": { + "identifier": 1, + "signing_key": "d4c9fd3791845b7de290023b97608a8d02a32884e07c3000625dc6763f978402", + "coefficient": "2c82ed212c86135dfb96d8fa101e14a9f7eaa68c3a7c631da8f923a339d4290d", + "vss_commitments": ["7a79f973094a1a3bf62a380ca55f7a4a14cfcedcbae5671c745689acf8db8a40", "7e12837ca7590e8bfd91f3d5a297e4471eb35dcde71a99ff8a74981c2622977e"], + "proof_of_knowledge": "72643991539e14296008902fa7f7083a5d65ada958e09cac3e78f66adf680564320bbeed85c87f98d00cc558de63e5394650b2d048f96bd9153bd223385aa902", + "signing_shares": { + "2": "37fd7a8fa7ef7e905c4cc1ca7a244672a3f90077a86746c1c95a0b8b2a7bbe09", + "3": "f93fcf4b8fd02dd5a84922b624e57bbb13ddc8e43ee8eab51380d09abbe62a02" + }, + "verifying_share": "34a6dfc4a2abd44c8fd4b1c25d4dd2b739fcd0769974e2bf043872ba888d6836", + "signing_share": "43b53fd8d96709e80c21c713698e814fb164996c0249c594e731c63f5fcd970b" + }, + "2": { + "identifier": 2, + "signing_key": "244e234486f729a9ce275e151ee0600028e7ae5177ab8fd3a33133492f8fae0a", + "coefficient": "00834da83b5b673f64c15a583b3ec4867b12522531bcb6ed2529d841fbeb0f0f", + "vss_commitments": ["86f699bf3f55baca2d2b1745cf131af2f9601f9b670abb2aa609edccb8c8b866", "7cff88ebfe8a35a5a362c53fe64f65f4e1fde0152265f4b0d267244cac1ac21d"], + "proof_of_knowledge": "549829af581c7728c47d609984a59f9c2de8743171c997c6cd1b300eba1970693718aceb9f7080a65e5ac9b58cd6c804d771572e6883086c9c7397869ecb9902", + "signing_shares": { + "1": "3ffae21ecf2d70df0222bc8ddaa2d3caf178769d5575f73ab2500ebdb23fd80c", + "3": "b2c44da0b4018ab427b4650b3925fe6e4537c1be14fb1e6515e4bca2216c6105" + }, + "verifying_share": "f2a45b7d4c5b18e7af08477e0a079fe80a0ce187794d34b7118b3c964ccd8f48", + "signing_share": "4e970d3d32b4bbb33eaa4e760c371e0956bc8af84394134fb7b8ae2cfa12080b" + }, + "3": { + "identifier": 3, + "signing_key": "2d8f46548402e44d007cd603ef9ed81ce282d00a69d5b606121ce4925561f40e", + "coefficient": "b9847e5425315cdf7e6a4355144082b3315af8d9d51234af0164ec0766853603", + "vss_commitments": ["90cf8b404afaa3050e8623695ebf24376b85eae516e31e40187f720fb337826a", "f6bcb935c8362dd673ebdc39b7c27620a6d8b4ad99b18d26c25c0aaf154a0023"], + "proof_of_knowledge": "840c009f88523ff9130c6306b2be6fea8fd6f1b0af58aa45760228a75f83f840d424f36af3a90b1c5807e646d86e064b285bf144b5f60f5a49785d602ab5010d", + "signing_shares": { + "1": "7ea8dae3e05071e4271c9de50cc7085fe9631d2a90f15a585a4a3260ec13020a", + "2": "5d5b2a26eadf285f7895873534ad10569a1ea5c10ae0b39c15adbb0e2153de07" + }, + "verifying_share": "0c7b8a84fbe0bb7d2b5d2748b21887832d0981df4faabd9dd503a3fd384ba26e", + "signing_share": "5979dba18a006e7f7033d6d8afdfbac2fa137c8485df6109873f97199558780a" + } + } + } diff --git a/frost-ristretto255/tests/integration_tests.rs b/frost-ristretto255/tests/integration_tests.rs index 5913f912..bacc9fb4 100644 --- a/frost-ristretto255/tests/integration_tests.rs +++ b/frost-ristretto255/tests/integration_tests.rs @@ -170,6 +170,9 @@ lazy_static! { pub static ref VECTORS_BIG_IDENTIFIER: Value = serde_json::from_str(include_str!("../tests/helpers/vectors-big-identifier.json").trim()) .expect("Test vector is valid JSON"); + pub static ref VECTORS_DKG: Value = + serde_json::from_str(include_str!("../tests/helpers/vectors_dkg.json").trim()) + .expect("Test vector is valid JSON"); } #[test] @@ -177,6 +180,11 @@ fn check_sign_with_test_vectors() { frost_core::tests::vectors::check_sign_with_test_vectors::(&VECTORS); } +#[test] +fn check_sign_with_test_vectors_dkg() { + frost_core::tests::vectors_dkg::check_dkg_keygen::(&VECTORS_DKG); +} + #[test] fn check_sign_with_test_vectors_with_big_identifiers() { frost_core::tests::vectors::check_sign_with_test_vectors::( diff --git a/frost-secp256k1/tests/helpers/vectors_dkg.json b/frost-secp256k1/tests/helpers/vectors_dkg.json new file mode 100644 index 00000000..90a8820d --- /dev/null +++ b/frost-secp256k1/tests/helpers/vectors_dkg.json @@ -0,0 +1,51 @@ +{ + "config": { + "MAX_PARTICIPANTS": 3, + "MIN_PARTICIPANTS": 2, + "name": "FROST(secp256k1, SHA-256)", + "group": "secp256k1", + "hash": "SHA-256" + }, + "inputs": { + "verifying_key": "037b5b0c4b6c91a16fb78499e8a74cc792f9ea79cb94860fcb90f801472930de47", + "1": { + "identifier": 1, + "signing_key": "e7a3cf1fdb1e17d4c3e8a7f663803ef305d03bdfdc930b824b0664c6b853156d", + "coefficient": "819adb51466d687c3944f8dad799a09551af9c083c918a50d9a24a883ae86e2a", + "vss_commitments": ["02dd81b7019efd1d38352b8df26a47d8e6bcb4ce7db71b2f9739b01031105294e2", "03cad1d1bc9d75de15ed0b4cb49dbde670d70988aa96d7982a25ee5484c97d3efc"], + "proof_of_knowledge": "0304df6af7f67b0d5f49ea2116f2d561a0a535c184836779f0f0677ff0838740ce20a0cb076384312f8817e030ca20379bab9247ee56fc3576b0b092f01c005691", + "signing_shares": { + "2": "3c4ae6fe69d55280cb06a0551f8563e526ee6f133a99433addcbb722a4c6f438", + "3": "e2454ec522749fc08388fed9c120b6ada8e1fd1e00026624c95b273f94dbf8a8" + }, + "verifying_share": "02b2597e19a037ba2eef224402a50652be93c1ab5bbd6195fc07ae6f6ecfa1304d", + "signing_share": "87cee034add572924bbd40001bbffa1db1f28a4bf52efebb4c2ad0978c71edf5" + }, + "2": { + "identifier": 2, + "signing_key": "ea163e297661aadf460b3de39a7550bd9b8fb2d07f1e1db5af098720156591a5", + "coefficient": "5234a8d4f373a7a184fb627185101326460d99296ac3c5c0ee948e8f5f97a3d4", + "vss_commitments": ["0280709e1bc38ca14a42f04dde31b33308d5a7ed7ef79a87c0cc14200783b519ac", "03490b38389a84ea57fde7b369962a92c53b367c221d5cd4728a7c6dfddb337c51"], + "proof_of_knowledge": "02afffa1f80fd46f2bac01bf7967649014a3a5236a62f32f98ce11fec20ee7229072c534d89a6b7b4c16129780404e172c3bdb527a77d40d760b80cc6538bcd4c4", + "signing_shares": { + "1": "ead985c267f8e8cd367299ac12b3801eee809709a66d7fe83e789b4a5dedb080", + "3": "39ee690094ac23a2373b35714ae7d3dc0e07e380bf547bf71758903d291a3e0b" + }, + "verifying_share": "03037adc4e0f796b96fc639ac194c1e167ccc5dd57505c813b0533b2bcd6d6ddaa", + "signing_share": "b3477e9659ee0691bdafd1e40230cb07aed5a5e05bd6649f625f12acbb304556" + }, + "3": { + "identifier": 3, + "signing_key": "8a9c3489b03d1bdecfd6c84237599980890d39d49167b016bb8b5fb530677204", + "coefficient": "57a91a3b723783e1b3b2369789c71d2d1fd4c3496e9ab60e0dcfc78a647486a4", + "vss_commitments": ["03f26b76678fe0174196430bb94e4e688044ae7bae2ccd7fef21c354429eb8bd61", "020d7a0d25b4ebed5157daf56aba2b89c3e0522f3bc293cc5e138f10e9c5efa465"], + "proof_of_knowledge": "02ad586ef180cda6bae1d2144ee090d277c77b789c8261349a247073626373cd8723b0ea6a62e8bc37372567ab4ef221d5e0a6c46d57d3746f6e5fde863298a542", + "signing_shares": { + "1": "6c746113ae6651496fb79286ea4d20b58581562b33b669fd58488745c89fdd69", + "2": "e0b438a850bca1c3d4fd653829a58a31b309a1661020cebcbaf4d44163f63be0" + }, + "verifying_share": "02f2198ff3f1e1de2249cdc59eb4ec926936892fa39fc1582861ad2e84681624b3", + "signing_share": "dec01cf806069a912fa263c7e8a19bf1abb8c174c27dca83789354c1e9ee9cb7" + } + } + } diff --git a/frost-secp256k1/tests/integration_tests.rs b/frost-secp256k1/tests/integration_tests.rs index 12d5d1a6..58ba3e08 100644 --- a/frost-secp256k1/tests/integration_tests.rs +++ b/frost-secp256k1/tests/integration_tests.rs @@ -170,6 +170,9 @@ lazy_static! { pub static ref VECTORS_BIG_IDENTIFIER: Value = serde_json::from_str(include_str!("../tests/helpers/vectors-big-identifier.json").trim()) .expect("Test vector is valid JSON"); + pub static ref VECTORS_DKG: Value = + serde_json::from_str(include_str!("../tests/helpers/vectors_dkg.json").trim()) + .expect("Test vector is valid JSON"); } #[test] @@ -177,6 +180,11 @@ fn check_sign_with_test_vectors() { frost_core::tests::vectors::check_sign_with_test_vectors::(&VECTORS); } +#[test] +fn check_sign_with_test_vectors_dkg() { + frost_core::tests::vectors_dkg::check_dkg_keygen::(&VECTORS_DKG); +} + #[test] fn check_sign_with_test_vectors_with_big_identifiers() { frost_core::tests::vectors::check_sign_with_test_vectors::(