diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /third_party/rust/prio/tests | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/prio/tests')
7 files changed, 252 insertions, 257 deletions
diff --git a/third_party/rust/prio/tests/discrete_gauss.rs b/third_party/rust/prio/tests/discrete_gauss.rs index 5b3ef4c5b3..d72138b64c 100644 --- a/third_party/rust/prio/tests/discrete_gauss.rs +++ b/third_party/rust/prio/tests/discrete_gauss.rs @@ -4,7 +4,7 @@ use num_bigint::{BigInt, BigUint}; use num_rational::Ratio; use num_traits::FromPrimitive; use prio::dp::distributions::DiscreteGaussian; -use prio::vdaf::xof::SeedStreamSha3; +use prio::vdaf::xof::SeedStreamTurboShake128; use rand::distributions::Distribution; use rand::SeedableRng; use serde::Deserialize; @@ -12,7 +12,7 @@ use serde::Deserialize; /// A test vector of discrete Gaussian samples, produced by the python reference /// implementation for [[CKS20]]. The script used to generate the test vector can /// be found in this gist: -/// https://gist.github.com/ooovi/529c00fc8a7eafd068cd076b78fc424e +/// https://gist.github.com/divergentdave/94cab188e84a4764db6cdd1288e6ead3 /// The python reference implementation is here: /// https://github.com/IBM/discrete-gaussian-differential-privacy /// @@ -29,20 +29,15 @@ pub struct DiscreteGaussTestVector { #[test] fn discrete_gauss_reference() { let test_vectors: Vec<DiscreteGaussTestVector> = vec![ - serde_json::from_str(include_str!(concat!("test_vectors/discrete_gauss_3.json"))).unwrap(), - serde_json::from_str(include_str!(concat!("test_vectors/discrete_gauss_9.json"))).unwrap(), - serde_json::from_str(include_str!(concat!( - "test_vectors/discrete_gauss_100.json" - ))) - .unwrap(), - serde_json::from_str(include_str!(concat!( - "test_vectors/discrete_gauss_41293847.json" - ))) - .unwrap(), - serde_json::from_str(include_str!(concat!( + serde_json::from_str(include_str!("test_vectors/discrete_gauss_3.json")).unwrap(), + serde_json::from_str(include_str!("test_vectors/discrete_gauss_9.json")).unwrap(), + serde_json::from_str(include_str!("test_vectors/discrete_gauss_100.json")).unwrap(), + serde_json::from_str(include_str!("test_vectors/discrete_gauss_41293847.json")).unwrap(), + serde_json::from_str(include_str!( "test_vectors/discrete_gauss_9999999999999999999999.json" - ))) + )) .unwrap(), + serde_json::from_str(include_str!("test_vectors/discrete_gauss_2.342.json")).unwrap(), ]; for test_vector in test_vectors { @@ -53,7 +48,7 @@ fn discrete_gauss_reference() { .unwrap(); // check samples are consistent - let mut rng = SeedStreamSha3::from_seed(test_vector.seed); + let mut rng = SeedStreamTurboShake128::from_seed(test_vector.seed); let samples: Vec<BigInt> = (0..test_vector.samples.len()) .map(|_| sampler.sample(&mut rng)) .collect(); diff --git a/third_party/rust/prio/tests/test_vectors/discrete_gauss_100.json b/third_party/rust/prio/tests/test_vectors/discrete_gauss_100.json index fe8114c258..84425db753 100644 --- a/third_party/rust/prio/tests/test_vectors/discrete_gauss_100.json +++ b/third_party/rust/prio/tests/test_vectors/discrete_gauss_100.json @@ -1,54 +1,54 @@ { "samples": [ - -74, + -54, + 61, + -113, + -98, + 21, + -91, + 72, + 112, + -29, 68, - -15, - 175, - -120, - -2, - -73, - 108, - 40, - 69, - 81, - -135, - 247, - 32, - 107, + 84, + -27, + -109, + -20, + -24, + -69, + -168, + 199, + -122, + 59, + 35, + 282, + 113, + 4, + -91, -61, - 164, - 22, - 118, - 37, - -58, - 147, - 65, - 53, - 9, - -96, - -130, - 100, - 48, + -28, + 137, + 57, + 109, + 2, + 17, + -20, + 38, + -16, + 18, + -63, + 1, + -20, -30, - -2, - -115, - 56, - 95, - 119, - 28, - -101, - 50, - 39, - 21, - -6, - -70, - 131, - 66, - 81, - -18, - 94, - 55, - 20 + -147, + -73, + -28, + -16, + -31, + 10, + -229, + -56, + -254 ], "seed": "000102030405060708090a0b0c0d0e0f", "std_denom": 1, diff --git a/third_party/rust/prio/tests/test_vectors/discrete_gauss_2.342.json b/third_party/rust/prio/tests/test_vectors/discrete_gauss_2.342.json index 7d9508c44e..c70e3b06e1 100644 --- a/third_party/rust/prio/tests/test_vectors/discrete_gauss_2.342.json +++ b/third_party/rust/prio/tests/test_vectors/discrete_gauss_2.342.json @@ -1,54 +1,54 @@ { "samples": [ -1, - 4, - 2, - 0, - 0, - -2, 1, - -5, + 6, 2, + -4, -1, - 0, - 0, - 0, - 3, - -6, - 5, + -2, 2, - 1, - -1, + -2, -3, 0, - 2, - -3, -2, + -1, + 3, 2, - -3, - 1, 1, 2, - -3, - -1, + -7, -1, + 0, 4, - 2, - -2, 1, -1, 0, - -3, + 1, + -2, + 0, 1, 2, + 0, + 6, + -2, + 2, + 0, + -2, + 2, + 6, 1, + 0, + -4, + -3, + -1, -1, - 3, - 1, 2, - -3, + 0, + 0, -2, - 0 + 0, + 2 ], "seed": "000102030405060708090a0b0c0d0e0f", "std_denom": 500, diff --git a/third_party/rust/prio/tests/test_vectors/discrete_gauss_3.json b/third_party/rust/prio/tests/test_vectors/discrete_gauss_3.json index d4a3486db0..363c136eb8 100644 --- a/third_party/rust/prio/tests/test_vectors/discrete_gauss_3.json +++ b/third_party/rust/prio/tests/test_vectors/discrete_gauss_3.json @@ -1,54 +1,54 @@ { "samples": [ - 1, + -3, -1, -2, 1, + 7, -1, - 0, - 1, - -1, - 0, - 2, - 3, - 4, - 1, - 1, -2, - 4, - 6, + 1, -5, + 1, -3, - -1, - 4, - 0, - 6, - 2, + 3, 2, - -4, - -2, -5, + -2, + 5, + -2, + 5, + -1, -3, 2, - 1, - -3, -2, - 1, + -1, -2, - 1, + -2, + -1, 0, - 3, - -4, - -4, 1, - 3, + -1, 2, - 1, - 0, + -3, + 2, + -6, + -4, + -2, + -2, + -6, -1, - 1, 4, - 1 + -1, + 2, + -3, + 1, + -7, + -1, + 6, + 2, + -3, + 5 ], "seed": "000102030405060708090a0b0c0d0e0f", "std_denom": 1, diff --git a/third_party/rust/prio/tests/test_vectors/discrete_gauss_41293847.json b/third_party/rust/prio/tests/test_vectors/discrete_gauss_41293847.json index 213e919c6c..247b2c2451 100644 --- a/third_party/rust/prio/tests/test_vectors/discrete_gauss_41293847.json +++ b/third_party/rust/prio/tests/test_vectors/discrete_gauss_41293847.json @@ -1,54 +1,54 @@ { "samples": [ - -10157810, - -7944688, - 80361481, - -2601121, - -2098394, - -61204295, - 250399, - 62702361, - -35117486, - 14804891, - -5043613, - 34131059, - -34448923, - -24176095, - 106518772, - 44056972, - 15910928, - 63338376, - 12839729, - 11701052, - -54254959, - -11306071, - -6005727, - 29738939, - -30284246, - -47672638, - 11549070, - -17580447, - -2973754, - -298465, - -15349002, - 56970396, - 35612502, - -78720214, - -6082493, - -2759887, - -11374460, - 177253, - -35234082, - 42256563, - 44219644, - 86984413, - -43711428, - -16031438, - 42572889, - 39464625, - -14433332, - -7735634, - 4403776 + -28705712, + 12839166, + 68574447, + 1993202, + 17416465, + 32526761, + 1212638, + -44876888, + 16502539, + -57954542, + -54567452, + -17421605, + 7569207, + 13482762, + -24573436, + 73067636, + -58069630, + -24924404, + 51409721, + -18659663, + -12752706, + 4308454, + -49095581, + -69009203, + -22975883, + 46983148, + 47341228, + -1860382, + 26901791, + -5079023, + -57635595, + -38560402, + 59065470, + 100046871, + -144954761, + -22089238, + -43816191, + -47986043, + 34106023, + 74194716, + -37681692, + 3946618, + 18344461, + -45770607, + -654004, + 31284526, + -50259979, + 28037461, + 2734567 ], "seed": "000102030405060708090a0b0c0d0e0f", "std_denom": 1, diff --git a/third_party/rust/prio/tests/test_vectors/discrete_gauss_9.json b/third_party/rust/prio/tests/test_vectors/discrete_gauss_9.json index 408c7489a7..b5df20d182 100644 --- a/third_party/rust/prio/tests/test_vectors/discrete_gauss_9.json +++ b/third_party/rust/prio/tests/test_vectors/discrete_gauss_9.json @@ -1,54 +1,54 @@ { "samples": [ - 2, - 14, - -12, - 10, - -13, - 1, - 6, - -10, + -6, + 7, + -3, + -7, + -14, + 4, + 11, + -22, -1, + 8, + -9, + 12, + -9, + 20, + -16, + -10, + -8, + -15, + 6, + -8, + 7, + 12, + 1, 4, + -3, + -7, + 20, + 2, + 13, + -4, -5, 1, - -20, - 1, - -14, + 2, + -2, + 4, + -6, 2, -5, - 10, - 3, - 9, - 10, - 12, - -4, - 12, - -4, - -13, - 7, - -10, -6, 2, - 6, - 18, - -7, - -11, - 20, - 1, - -4, - 14, - 11, - 5, - 6, - -1, 2, - 5, - 3, - -8, - -1, - 6, - -8 + -5, + -10, + -9, + -15, + -2, + -3, + 1, + -13 ], "seed": "000102030405060708090a0b0c0d0e0f", "std_denom": 1, diff --git a/third_party/rust/prio/tests/test_vectors/discrete_gauss_9999999999999999999999.json b/third_party/rust/prio/tests/test_vectors/discrete_gauss_9999999999999999999999.json index 396f5a4cf0..1b43f758bd 100644 --- a/third_party/rust/prio/tests/test_vectors/discrete_gauss_9999999999999999999999.json +++ b/third_party/rust/prio/tests/test_vectors/discrete_gauss_9999999999999999999999.json @@ -1,54 +1,54 @@ { "samples": [ - 7826646418794481373730, - 4044429794334089153683, - -13887062284591122240746, - 4816851335312673293131, - 1899078604295677453383, - -7819872990828024151405, - 1164017821807881486579, - -25360379570365624087817, - 5906637163630390455939, - 3730592807287609262846, - 1737147847266613603450, - 18593764766679058926154, - 22724295990478919946193, - -4396717652132313983045, - -7933138830987043774425, - 12204708418993708917398, - 10716232788607487693156, - -7423575920998904747964, - -274262846168968742506, - -24595460253341309777726, - 1880635641243101726137, - 10823060437484007979521, - -2525077352000184270857, - -1421364839539048815904, - -2648842672480402351562, - -7783156811031000955203, - -1831198454606609539077, - 905920470298728568753, - -8805882598094077859729, - 2949974625887521817722, - 13071000629486423981714, - 1311702736683393895126, - -14044034250430823347919, - 1421736709768854180193, - 14824744520414922652958, - 10752031849750698732804, - -522118577625103067952, - 2006618532306506057615, - -7573105805904097888275, - -14482966128638641002042, - -11408400475022385123481, - -17555433966245180572099, - -6120185353438187140929, - -4778266138627264471521, - -19325342657405318133711, - 3725950229250476135126, - -7977400544074383347686, - 2738166449787592433931, - -1321521809406566447071 + -7678632936135800555201, + -9832864446958915374632, + 3796223649719723548306, + -10458306547534276720045, + -9593524715689396783652, + -2184509652523057908030, + -6469904065015921866985, + 8555843521262785582921, + -3275061234860213279391, + -1712551617443682313245, + -4176263950279049852314, + -1041488124720108532833, + 2422891656983904955539, + -5406575579403973625234, + 4031989610743156091985, + -15897376981820943559856, + -9495308497775799052592, + -10542231739931574778478, + -811195020079942319200, + -6168725392123782999911, + 3572639345203916100181, + 9572138148079890711898, + 12973597810318272581841, + -10417671747756128178069, + -4499306785200793424437, + 24392853538076877246695, + 490509578119404728479, + -3153758591414179213424, + -2953031165864251687043, + 7687220020362800379045, + -2894825604535601473288, + -2484898457763802405625, + 2506976850588238983075, + -317271622218426183645, + 3771644622097191550823, + 14048201376263257821999, + 1011626374739477364716, + -7985335097085684878144, + -9834946916794550716888, + -7808156770298839154888, + -10888303506419120919014, + 20441738459254393472434, + -1142146934147582936699, + -380992974206599694131, + 14719724965924743443097, + 2738534455216435603182, + 16889459715609520924993, + 8450917371339563018232, + 3461026365290831355984 ], "seed": "000102030405060708090a0b0c0d0e0f", "std_denom": 1, |