diff --git a/examples/digital_locker.rs b/examples/digital_locker.rs index d26cbf5..045f1f6 100644 --- a/examples/digital_locker.rs +++ b/examples/digital_locker.rs @@ -32,7 +32,6 @@ use std::process::exit; use opaque_ke::{ ciphersuite::CipherSuite, - keypair::PrivateKey, rand::{rngs::OsRng, RngCore}, ClientLogin, ClientLoginFinishParameters, ClientRegistration, ClientRegistrationFinishParameters, CredentialFinalization, CredentialRequest, @@ -49,7 +48,6 @@ impl CipherSuite for Default { type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; type Hash = sha2::Sha512; type SlowHash = opaque_ke::slow_hash::NoOpHash; - type PrivateKey = PrivateKey; } struct Locker { diff --git a/examples/simple_login.rs b/examples/simple_login.rs index bf2bcb1..f8f42e0 100644 --- a/examples/simple_login.rs +++ b/examples/simple_login.rs @@ -26,11 +26,10 @@ use std::collections::HashMap; use std::process::exit; use opaque_ke::{ - ciphersuite::CipherSuite, keypair::PrivateKey, rand::rngs::OsRng, ClientLogin, - ClientLoginFinishParameters, ClientRegistration, ClientRegistrationFinishParameters, - CredentialFinalization, CredentialRequest, CredentialResponse, RegistrationRequest, - RegistrationResponse, RegistrationUpload, ServerLogin, ServerLoginStartParameters, - ServerRegistration, ServerSetup, + ciphersuite::CipherSuite, rand::rngs::OsRng, ClientLogin, ClientLoginFinishParameters, + ClientRegistration, ClientRegistrationFinishParameters, CredentialFinalization, + CredentialRequest, CredentialResponse, RegistrationRequest, RegistrationResponse, + RegistrationUpload, ServerLogin, ServerLoginStartParameters, ServerRegistration, ServerSetup, }; // The ciphersuite trait allows to specify the underlying primitives @@ -42,7 +41,6 @@ impl CipherSuite for Default { type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; type Hash = sha2::Sha512; type SlowHash = opaque_ke::slow_hash::NoOpHash; - type PrivateKey = PrivateKey; } // Password-based registration between a client and server diff --git a/src/ciphersuite.rs b/src/ciphersuite.rs index 8b55e9a..9c90601 100644 --- a/src/ciphersuite.rs +++ b/src/ciphersuite.rs @@ -6,8 +6,8 @@ //! Defines the CipherSuite trait to specify the underlying primitives for OPAQUE use crate::{ - hash::Hash, key_exchange::traits::KeyExchange, keypair::SecretKey, - map_to_curve::GroupWithMapToCurve, slow_hash::SlowHash, + hash::Hash, key_exchange::traits::KeyExchange, map_to_curve::GroupWithMapToCurve, + slow_hash::SlowHash, }; use digest::Digest; @@ -31,6 +31,4 @@ pub trait CipherSuite { type Hash: Hash; /// A slow hashing function, typically used for password hashing type SlowHash: SlowHash; - /// A private key container, allows remote key implementations - type PrivateKey: SecretKey; } diff --git a/src/lib.rs b/src/lib.rs index 2ad7200..8857e2c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,6 @@ //! type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! type Hash = sha2::Sha512; //! type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! type PrivateKey = opaque_ke::keypair::PrivateKey; //! } //! ``` //! See [examples/simple_login.rs](https://github.com/novifinancial/opaque-ke/blob/master/examples/simple_login.rs) @@ -48,7 +47,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! use rand::{rngs::OsRng, RngCore}; //! let mut rng = OsRng; @@ -81,7 +79,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! use opaque_ke::ClientRegistration; //! use rand::{rngs::OsRng, RngCore}; @@ -112,7 +109,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -150,7 +146,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -189,7 +184,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -232,7 +226,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! use opaque_ke::ClientLogin; @@ -266,7 +259,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -320,7 +312,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -366,7 +357,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -442,7 +432,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -520,7 +509,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -586,7 +574,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -624,7 +611,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; @@ -674,7 +660,6 @@ //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; -//! # type PrivateKey = opaque_ke::keypair::PrivateKey; //! # } //! # use rand::{rngs::OsRng, RngCore}; //! # let mut client_rng = OsRng; diff --git a/src/opaque.rs b/src/opaque.rs index 7c3bd4d..fa573f4 100644 --- a/src/opaque.rs +++ b/src/opaque.rs @@ -41,23 +41,20 @@ const STR_OPAQUE_DERIVE_KEY_PAIR: &[u8] = b"OPAQUE-DeriveKeyPair"; feature = "serialize", derive(serde::Deserialize, serde::Serialize), serde(bound( - deserialize = "KeyPair: serde::Deserialize<'de>", - serialize = "KeyPair: serde::Serialize" + deserialize = "KeyPair: serde::Deserialize<'de>", + serialize = "KeyPair: serde::Serialize" )) )] -pub struct ServerSetup { +pub struct ServerSetup< + CS: CipherSuite, + S: SecretKey = PrivateKey<::Group>, +> { oprf_seed: GenericArray::OutputSize>, - keypair: KeyPair, + keypair: KeyPair, pub(crate) fake_keypair: KeyPair, } -impl< - CS: CipherSuite>, - G: Group + GroupWithMapToCurve::OutputSize>, - > ServerSetup -where - ::KeyExchange: KeyExchange<::Hash, G>, -{ +impl ServerSetup> { /// Generate a new instance of server setup pub fn new(rng: &mut R) -> Self { let mut seed = vec![0u8; ::OutputSize::to_usize()]; @@ -71,7 +68,7 @@ where } } -impl ServerSetup { +impl> ServerSetup { /// Serialization into bytes pub fn serialize(&self) -> Vec { [ @@ -96,7 +93,7 @@ impl ServerSetup { } /// Returns the keypair - pub fn keypair(&self) -> &KeyPair { + pub fn keypair(&self) -> &KeyPair { &self.keypair } } diff --git a/src/serialization/tests.rs b/src/serialization/tests.rs index fbe5c13..9109a92 100644 --- a/src/serialization/tests.rs +++ b/src/serialization/tests.rs @@ -12,7 +12,7 @@ use crate::{ traits::{FromBytes, KeyExchange, ToBytes}, tripledh::{NonceLen, TripleDH}, }, - keypair::{KeyPair, PrivateKey, PublicKey}, + keypair::{KeyPair, PublicKey}, serialization::{i2osp, os2ip, serialize}, *, }; @@ -31,7 +31,6 @@ impl CipherSuite for Default { type KeyExchange = TripleDH; type Hash = sha2::Sha512; type SlowHash = crate::slow_hash::NoOpHash; - type PrivateKey = PrivateKey; } const HASH_SIZE: usize = 64; // Because of SHA512 diff --git a/src/tests/full_test.rs b/src/tests/full_test.rs index 2586c0f..a79f089 100644 --- a/src/tests/full_test.rs +++ b/src/tests/full_test.rs @@ -10,7 +10,7 @@ use crate::{ errors::*, group::Group, key_exchange::tripledh::{NonceLen, TripleDH}, - keypair::{KeyPair, PrivateKey}, + keypair::KeyPair, opaque::*, slow_hash::NoOpHash, tests::mock_rng::CycleRng, @@ -33,7 +33,6 @@ impl CipherSuite for RistrettoSha5123dhNoSlowHash { type KeyExchange = TripleDH; type Hash = sha2::Sha512; type SlowHash = NoOpHash; - type PrivateKey = PrivateKey; } pub struct TestVectorParameters { diff --git a/src/tests/opaque_test_vectors.rs b/src/tests/opaque_test_vectors.rs index 4ac7118..22b16a9 100644 --- a/src/tests/opaque_test_vectors.rs +++ b/src/tests/opaque_test_vectors.rs @@ -21,7 +21,6 @@ impl CipherSuite for Ristretto255Sha512NoSlowHash { type KeyExchange = TripleDH; type Hash = sha2::Sha512; type SlowHash = NoOpHash; - type PrivateKey = PrivateKey; } #[derive(PartialEq)]