diff --git a/common/Cargo.toml b/common/Cargo.toml index c5d9876..32c1f5e 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -12,26 +12,24 @@ path = "datagen/datagen.rs" [dependencies] -log = "0.4" -env_logger = "0.7.1" -rayon = "1.8.0" -clap = "2.33.0" -csv = "1.1.1" -rand = { version = "0.8", features = ["small_rng"] } -indicatif = "0.13.0" -hex = "0.3.0" -serde = {version = "1.0.104", features = ["derive"] } -num = "0.2.1" -wasm-timer = "0.2.5" aws-config = "0.56.1" aws-credential-types = "0.56.1" aws-sdk-s3 = "0.34.0" aws-smithy-http = "0.56.0" +clap = "2.33.0" +cloud-storage = "0.10" +csv = "1.1.1" +env_logger = "0.7.1" +hex = "0.3.0" +indicatif = "0.13.0" lazy_static = "1.4.0" +log = "0.4" +rand = { version = "0.8", features = ["small_rng"] } +rayon = "1.8.0" regex = "1.5.4" +serde = { version = "1.0.104", features = ["derive"] } +serde_json = "1.0" tempfile = "3.2.0" thiserror = "1.0.25" tokio = { version = "1", features = ["full"] } -cloud-storage = "0.10" tokio-util = { version = "0.6.9", features = ["codec"] } -serde_json = "1.0" diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml index a7d5d58..c011dfe 100644 --- a/crypto/Cargo.toml +++ b/crypto/Cargo.toml @@ -7,24 +7,17 @@ version = "0.1.0" authors = ["Facebook Inc"] edition = "2021" -[features] -avx2 = ["curve25519-dalek/simd_backend"] - [dependencies] -log = "0.4" -env_logger = "0.7.1" -sha2 = "0.9.0" -hex = "0.4.0" -rand = "0.8" -rand_core = "0.5.1" -curve25519-dalek = "3.2" Cupcake = { git = "https://github.com/facebookresearch/Cupcake"} -rayon = "1.8.0" -serde = {version = "1.0.104", features = ["derive"] } -bincode = "1.2.1" +curve25519-dalek = { version = "4", features = ["digest", "rand_core"] } num-bigint = { version = "0.4", features = ["rand"] } -num-traits = "0.2" num-integer = "0.1" +num-traits = "0.2" +rand = "0.8" +rand_core = "0.6" +rayon = "1.8.0" +serde = {version = "1.0.104", features = ["derive"] } +sha2 = "0.10.6" [dev-dependencies] criterion = "0.2" diff --git a/crypto/src/eccipher.rs b/crypto/src/eccipher.rs index 6afb150..ff71b44 100644 --- a/crypto/src/eccipher.rs +++ b/crypto/src/eccipher.rs @@ -120,6 +120,7 @@ impl ECCipher for ECRistrettoSequential { .iter() .map(|b| { CompressedRistretto::from_slice(&b.buffer) + .expect("Failed to construct compressed point") .decompress() .unwrap() }) @@ -131,6 +132,7 @@ impl ECCipher for ECRistrettoSequential { .iter() .map(|b| { let p = CompressedRistretto::from_slice(&b.buffer) + .expect("Failed to construct compressed point") .decompress() .unwrap(); p * pow @@ -234,6 +236,7 @@ impl ECCipher for ECRistrettoParallel { .into_par_iter() .map(|item| { CompressedRistretto::from_slice(&item.buffer) + .expect("Failed to construct compressed point") .decompress() .unwrap() }) @@ -267,6 +270,7 @@ impl ECCipher for ECRistrettoParallel { .into_par_iter() .map(|item| { let p = CompressedRistretto::from_slice(&item.buffer) + .expect("Failed to construct compressed point") .decompress() .unwrap(); p * pow diff --git a/protocol-rpc/Cargo.toml b/protocol-rpc/Cargo.toml index 248d8b3..53dfcc8 100644 --- a/protocol-rpc/Cargo.toml +++ b/protocol-rpc/Cargo.toml @@ -89,38 +89,33 @@ path = "src/rpc/dspmc/client.rs" name = "rpc" path = "src/lib.rs" -[features] -avx2 = ["crypto/avx2"] - [dependencies] common = {path = "../common", version = "0.1.0"} crypto = {path = "../crypto", version = "0.1.0"} protocol = {path = "../protocol", version = "0.1.0"} -log = "0.4" -env_logger = "0.7.1" -tonic = { version = "0.7.2", features = ["tls", "tls-roots", "prost"]} -tokio = { version = "1.18.2", features = ["rt-multi-thread", "time", "fs", "macros", "net"] } -tokio-stream = { version = "0.1.8", features = ["net"] } -tower = { version = "0.4.12" } -prost = "0.10" -futures = { version = "0.3", features = ["thread-pool", "alloc"]} -http = "0.2" -url = "2.1.0" async-stream = "0.2" -rayon = "1.8.0" bytes = "0.4" clap = "2.33.4" csv = "1.1.1" -indicatif = "0.13.0" ctrlc = "3.2.3" -retry = "0.5.1" -bincode = "1.2.1" +env_logger = "0.7.1" +futures = { version = "0.3", features = ["thread-pool", "alloc"]} +http = "0.2" itertools = "0.9.0" -tempfile = "3.2.0" +log = "0.4" num-bigint = { version = "0.4", features = ["rand"] } num-traits = "0.2" +prost = "0.10" +rayon = "1.8.0" rcgen = "0.10.0" +retry = "0.5.1" +tempfile = "3.2.0" +tokio = { version = "1.18.2", features = ["rt-multi-thread", "time", "fs", "macros", "net"] } +tokio-stream = { version = "0.1.8", features = ["net"] } +tonic = { version = "0.7.2", features = ["tls", "tls-roots", "prost"]} +tower = { version = "0.4.12" } +url = "2.1.0" [build-dependencies] tonic-build = { version = "0.7.2" } diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index 547435a..b31027e 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -12,20 +12,19 @@ edition = "2021" [dependencies] common = {path = "../common", version = "0.1.0"} crypto = {path = "../crypto", version = "0.1.0"} -serde_json = "1.0" -log = "0.4" -env_logger = "0.7.1" +base64 = "0.13" csv = "1.1.1" -itertools = "0.9.0" -rand = "0.8" -rand_core = "0.5.1" +fernet = "0.2.1" hex = "0.4.2" -rayon = "1.8.0" +itertools = "0.9.0" +log = "0.4" +mockall = "0.10.2" num-bigint = { version = "0.4", features = ["rand"] } num-traits = "0.2" -zeroize = "1.5.5" +rand = "0.8" +rand_core = "0.6" +rayon = "1.8.0" +serde_json = "1.0" tempfile = "3.2.0" -mockall = "0.10.2" -fernet = "0.2.1" -base64 = "0.13" +zeroize = "1.5.5" diff --git a/protocol/src/dpmc/company.rs b/protocol/src/dpmc/company.rs index 3a73f96..8bf838e 100644 --- a/protocol/src/dpmc/company.rs +++ b/protocol/src/dpmc/company.rs @@ -55,7 +55,7 @@ impl CompanyDpmc { let x = gen_scalar(); CompanyDpmc { keypair_sk: x, - keypair_pk: &x * &RISTRETTO_BASEPOINT_TABLE, + keypair_pk: &x * RISTRETTO_BASEPOINT_TABLE, private_beta: gen_scalar(), ec_cipher: ECRistrettoParallel::default(), plaintext: Arc::new(RwLock::default()), diff --git a/protocol/src/dpmc/helper.rs b/protocol/src/dpmc/helper.rs index c8fae65..27a9455 100644 --- a/protocol/src/dpmc/helper.rs +++ b/protocol/src/dpmc/helper.rs @@ -60,7 +60,7 @@ impl HelperDpmc { let x = gen_scalar(); HelperDpmc { keypair_sk: x, - keypair_pk: &x * &RISTRETTO_BASEPOINT_TABLE, + keypair_pk: &x * RISTRETTO_BASEPOINT_TABLE, company_public_key: Arc::new(RwLock::default()), ec_cipher: ECRistrettoParallel::default(), self_permutation: Arc::new(RwLock::default()), @@ -168,7 +168,7 @@ impl HelperDpmcProtocol for HelperDpmc { let alpha_t = { let ctxt_str: String = String::from_utf8(enc_alpha_t.clone()).unwrap(); - Scalar::from_bits( + Scalar::from_bytes_mod_order( Fernet::new(&aes_key) .unwrap() .decrypt(&ctxt_str) @@ -519,7 +519,7 @@ impl HelperDpmcProtocol for HelperDpmc { .collect::>(); let y = z_i .iter() - .map(|a| a * &RISTRETTO_BASEPOINT_TABLE) + .map(|a| a * RISTRETTO_BASEPOINT_TABLE) .collect::>(); (x, y) }; diff --git a/protocol/src/dpmc/partner.rs b/protocol/src/dpmc/partner.rs index 2a8146c..6ffaa15 100644 --- a/protocol/src/dpmc/partner.rs +++ b/protocol/src/dpmc/partner.rs @@ -41,7 +41,7 @@ impl PartnerDpmc { let x = gen_scalar(); PartnerDpmc { keypair_sk: x, - keypair_pk: &x * &RISTRETTO_BASEPOINT_TABLE, + keypair_pk: &x * RISTRETTO_BASEPOINT_TABLE, partner_scalar: gen_scalar(), company_public_key: Arc::new(RwLock::default()), helper_public_key: Arc::new(RwLock::default()), @@ -185,7 +185,7 @@ impl PartnerDpmcProtocol for PartnerDpmc { let p_scalar_times_g = self .ec_cipher - .to_bytes(&[&self.partner_scalar * &RISTRETTO_BASEPOINT_TABLE]); + .to_bytes(&[&self.partner_scalar * RISTRETTO_BASEPOINT_TABLE]); d_flat.extend(p_scalar_times_g); Ok(d_flat) @@ -261,7 +261,7 @@ impl PartnerDpmcProtocol for PartnerDpmc { let g_zi = { let t = z_i .iter() - .map(|x| x * &RISTRETTO_BASEPOINT_TABLE) + .map(|x| x * RISTRETTO_BASEPOINT_TABLE) .collect::>(); self.ec_cipher.to_bytes(&t) }; diff --git a/protocol/src/dspmc/company.rs b/protocol/src/dspmc/company.rs index 4ca1b70..2b1541f 100644 --- a/protocol/src/dspmc/company.rs +++ b/protocol/src/dspmc/company.rs @@ -63,8 +63,8 @@ impl CompanyDspmc { CompanyDspmc { keypair_sk: (x1, x2), keypair_pk: ( - &x1 * &RISTRETTO_BASEPOINT_TABLE, - &x2 * &RISTRETTO_BASEPOINT_TABLE, + &x1 * RISTRETTO_BASEPOINT_TABLE, + &x2 * RISTRETTO_BASEPOINT_TABLE, ), helper_public_key: Arc::new(RwLock::default()), ec_cipher: ECRistrettoParallel::default(), diff --git a/protocol/src/dspmc/helper.rs b/protocol/src/dspmc/helper.rs index f58d9fa..21e08b4 100644 --- a/protocol/src/dspmc/helper.rs +++ b/protocol/src/dspmc/helper.rs @@ -52,7 +52,7 @@ impl HelperDspmc { let x = gen_scalar(); HelperDspmc { keypair_sk: x, - keypair_pk: &x * &RISTRETTO_BASEPOINT_TABLE, + keypair_pk: &x * RISTRETTO_BASEPOINT_TABLE, ec_cipher: ECRistrettoParallel::default(), company_public_key: Arc::new(RwLock::default()), xor_shares_v2: Arc::new(RwLock::default()), @@ -641,7 +641,7 @@ impl HelperDspmcProtocol for HelperDspmc { .collect::>(); let y = z_i .iter() - .map(|a| a * &RISTRETTO_BASEPOINT_TABLE) + .map(|a| a * RISTRETTO_BASEPOINT_TABLE) .collect::>(); (x, y) }; diff --git a/protocol/src/dspmc/partner.rs b/protocol/src/dspmc/partner.rs index 58c5392..bce0349 100644 --- a/protocol/src/dspmc/partner.rs +++ b/protocol/src/dspmc/partner.rs @@ -192,7 +192,7 @@ impl PartnerDspmcProtocol for PartnerDspmc { // PRG seed = scalar * PK_helper let (seed, ct3) = { let x = gen_scalar(); - let ct3 = self.ec_cipher.to_bytes(&[&x * &RISTRETTO_BASEPOINT_TABLE]); + let ct3 = self.ec_cipher.to_bytes(&[&x * RISTRETTO_BASEPOINT_TABLE]); let seed: [u8; 32] = { let t = self.ec_cipher.to_bytes(&[x * (*helper_pk)]); t[0].buffer.as_slice().try_into().expect("incorrect length") diff --git a/protocol/src/dspmc/shuffler.rs b/protocol/src/dspmc/shuffler.rs index a8cc0a1..814ff9f 100644 --- a/protocol/src/dspmc/shuffler.rs +++ b/protocol/src/dspmc/shuffler.rs @@ -398,7 +398,7 @@ impl ShufflerDspmcProtocol for ShufflerDspmc { let g_zi = { let t = z_i .iter() - .map(|x| x * &RISTRETTO_BASEPOINT_TABLE) + .map(|x| x * RISTRETTO_BASEPOINT_TABLE) .collect::>(); self.ec_cipher.to_bytes(&t) }; diff --git a/protocol/src/private_id_multi_key/company.rs b/protocol/src/private_id_multi_key/company.rs index cefd0c6..a93a03e 100644 --- a/protocol/src/private_id_multi_key/company.rs +++ b/protocol/src/private_id_multi_key/company.rs @@ -526,7 +526,7 @@ mod tests { 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, ]; - Scalar::from_bits(l_plus_two_bytes) + Scalar::from_bytes_mod_order(l_plus_two_bytes) } #[test] diff --git a/protocol/src/private_id_multi_key/partner.rs b/protocol/src/private_id_multi_key/partner.rs index 2c6a279..17ec72e 100644 --- a/protocol/src/private_id_multi_key/partner.rs +++ b/protocol/src/private_id_multi_key/partner.rs @@ -287,7 +287,7 @@ mod tests { 0xde, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, ]; - Scalar::from_bits(l_plus_two_bytes) + Scalar::from_bytes_mod_order(l_plus_two_bytes) } #[test] diff --git a/protocol/src/suid_create/mod.rs b/protocol/src/suid_create/mod.rs index 0d249a0..008c6bc 100644 --- a/protocol/src/suid_create/mod.rs +++ b/protocol/src/suid_create/mod.rs @@ -136,7 +136,7 @@ fn serialize_helper(data: Vec>) -> (Vec, TPayload, TPayload) { fn gen_elgamal_keypair() -> (Scalar, TPoint) { let private_key = gen_scalar(); - let public_key = &private_key * &RISTRETTO_BASEPOINT_TABLE; + let public_key = &private_key * RISTRETTO_BASEPOINT_TABLE; (private_key, public_key) } @@ -173,7 +173,7 @@ fn elgamal_encrypt(data: Vec, public_key: &TPoint) -> (Vec, Vec< let c1 = r .iter() - .map(|x| x * &RISTRETTO_BASEPOINT_TABLE) + .map(|x| x * RISTRETTO_BASEPOINT_TABLE) .collect::>(); let c2 = data