diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/prio/tests | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/prio/tests')
-rw-r--r-- | third_party/rust/prio/tests/backward_compatibility.rs | 31 | ||||
-rw-r--r-- | third_party/rust/prio/tests/test_vectors/fieldpriov2.json | 31 |
2 files changed, 62 insertions, 0 deletions
diff --git a/third_party/rust/prio/tests/backward_compatibility.rs b/third_party/rust/prio/tests/backward_compatibility.rs new file mode 100644 index 0000000000..55338c10cc --- /dev/null +++ b/third_party/rust/prio/tests/backward_compatibility.rs @@ -0,0 +1,31 @@ +use prio::{test_vector::Priov2TestVector, util::reconstruct_shares}; + +#[test] +fn priov2_backward_compatibility() { + let test_vector: Priov2TestVector = + serde_json::from_str(include_str!("test_vectors/fieldpriov2.json")).unwrap(); + + let mut server1 = test_vector.server_1().unwrap(); + let mut server2 = test_vector.server_2().unwrap(); + + for (server_1_share, server_2_share) in test_vector + .server_1_shares + .iter() + .zip(&test_vector.server_2_shares) + { + let eval_at = server1.choose_eval_at(); + + let v1 = server1 + .generate_verification_message(eval_at, server_1_share) + .unwrap(); + let v2 = server2 + .generate_verification_message(eval_at, server_2_share) + .unwrap(); + + assert!(server1.aggregate(server_1_share, &v1, &v2).unwrap()); + assert!(server2.aggregate(server_2_share, &v1, &v2).unwrap()); + } + + let reconstructed = reconstruct_shares(server1.total_shares(), server2.total_shares()).unwrap(); + assert_eq!(reconstructed, test_vector.reference_sum); +} diff --git a/third_party/rust/prio/tests/test_vectors/fieldpriov2.json b/third_party/rust/prio/tests/test_vectors/fieldpriov2.json new file mode 100644 index 0000000000..30f896b674 --- /dev/null +++ b/third_party/rust/prio/tests/test_vectors/fieldpriov2.json @@ -0,0 +1,31 @@ +{ + "server_1_private_key": "BIl6j+J6dYttxALdjISDv6ZI4/VWVEhUzaS05LgrsfswmbLOgNt9HUC2E0w+9RqZx3XMkdEHBHfNuCSMpOwofVSq3TfyKwn0NrftKisKKVSaTOt5seJ67P5QL4hxgPWvxw==", + "server_2_private_key": "BNNOqoU54GPo+1gTPv+hCgA9U2ZCKd76yOMrWa1xTWgeb4LhFLMQIQoRwDVaW64g/WTdcxT4rDULoycUNFB60LER6hPEHg/ObBnRPV1rwS3nj9Bj0tbjVPPyL9p8QW8B+w==", + "dimension": 10, + "server_1_shares": [ + "BOLHuvkvD7N3jfTxwrvHq+O7zEJJ++Ar7439Cr1Z7NfEUO1Z6w0LLs8Koro3Ma1ej4EOyrguwrbANRQMeWMIoOsbYCdy2w1GKIZLpLiaW0OsshAJ2LSUOoZZt2bet9mMe4BH+86hBLpncZZGeW335UIz4PCkOXOgK30FrP1pMEqtMoOuxWBkpwuaWqmCKMmdWe/I+Bb9TUL5mwIM+M8jnI0N9Y7XBmRWEeW/m1ji0zL0AndgkPIYyvMfOokGLdxXhAq5HyQ=", + "BFjYcYjJ3HRGHZfIMNNyd5+qpBpoSEIUWOH6PwXrQyT2PpEwVQuX+wA2tW8/KR4cgmg/OmT0YjEPdFsvy7Eemzdsx6jOZMkiC9eCpkQDre796eyl8aZD1LM5IOsk7StKYZHBXKZrIPfRI375WQfCi7LNaUGpa6qBmphLwu+5HSVt+PVqnWIKsl30jZFpt/53DJUbknVOYBj0pMmQnuNPPbpFoq5GZxGQQOEf7GLpaowl8tUgGYOagACSUvbL77h9zvlAlNM=", + "BI7WE02BRvKAV/n/sJ28Nm5vlGokeeDLqEyTRPRi8Ud/4Dy1qfkxbPm7dOW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dAaSO8D4eAhQKg5o1bJy+p2NRVMrfc6BjgBEejTz6FixWQuYcBygbHturW8EnIm/1AUU8YLbz1cHZddjxqBUmIapQg5xMrsDggZH3xIoZzQ=", + "BDWpotQorKrwzmMMwIJQcVqHT+cPkGa1QPZM9W5HFgqkURgIuJhbaAkOk7oix84fVCxOxoO+/spY2vUNn8r+0CQu3g21EcL9AzZwtEjZHjXVLZ6xLWz3v+eFB8yLT635CXisXx7wXeWUd6jp44MunqA=", + "BM0/op40IsjhByCx8+1oXTEe2DglHUNatUHDzR/SDIlkkA0yfpK1D345YE+83yOJmuQO1wKa7TrMeqPfTdaoYAwUkibWmisTdKQd4mljghwf7ECWh5Vy6kwfu0KMBtHbvJj9ti55+kWWOqwNtLzDL1I=" + ], + "reference_sum": "BgAAAAcAAAAEAAAABQAAAAkAAAAGAAAAAgAAAAYAAAAEAAAABQAAAA==", + "prio_crate_version": "0.5.0" +} |