General Improvements (#268)
* Move `elliptic-curve` implementation to points to allow `Zeroize` * Simplify `Ristretto255::random_scalar` implementation * Fix `Ristretto255` deserialization * Remove unnecessary check in `Ristretto255::random_scalar` * Base `X25519` implementation on `curve25519-dalek` * Constrain public and secret key to `Copy` * Replace manual `ZeroizeOnDrop` implementation with `derive` * Update dependencies * Add `warn(unused_crate_dependencies)` * Sync crate feature naming with `voprf` * Remove unnecessary dependency crate features * Never produce a zero scalar * Rename `OprfGroup` to `OprfCs` * Rename `TripleDH` to `TripleDh` * Remove `slow-hash` crate feature * Rename `NoOpHash` to `Identity` * Rename `SlowHash` to `Ksf` * Move `KeyExchange` type definitions down * Deserialize secret and public keys from slices * Remove `PrivateKey::from_bytes` * Rename `From/ToBytes` to `De/Serialize` * Re-export `serde_` as `serde` * Custom `De/Serialize` implementation for keys * Remove custom `De/Serialize` implementation * Run Taplo v0.6
This commit is contained in:
+36
-36
@@ -18,39 +18,17 @@ use crate::hash::{Hash, ProxyHash};
|
||||
use crate::key_exchange::group::KeGroup;
|
||||
use crate::keypair::{PrivateKey, PublicKey, SecretKey};
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub type GenerateKe2Result<K, D, G> = (
|
||||
<K as KeyExchange<D, G>>::KE2State,
|
||||
<K as KeyExchange<D, G>>::KE2Message,
|
||||
);
|
||||
#[cfg(test)]
|
||||
pub type GenerateKe2Result<K, D, G> = (
|
||||
<K as KeyExchange<D, G>>::KE2State,
|
||||
<K as KeyExchange<D, G>>::KE2Message,
|
||||
Output<D>,
|
||||
Output<D>,
|
||||
);
|
||||
#[cfg(not(test))]
|
||||
pub type GenerateKe3Result<K, D, G> = (Output<D>, <K as KeyExchange<D, G>>::KE3Message);
|
||||
#[cfg(test)]
|
||||
pub type GenerateKe3Result<K, D, G> = (
|
||||
Output<D>,
|
||||
<K as KeyExchange<D, G>>::KE3Message,
|
||||
Output<D>,
|
||||
Output<D>,
|
||||
);
|
||||
|
||||
pub trait KeyExchange<D: Hash, G: KeGroup>
|
||||
where
|
||||
D::Core: ProxyHash,
|
||||
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
|
||||
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
|
||||
{
|
||||
type KE1State: FromBytes + ToBytes + ZeroizeOnDrop + Clone;
|
||||
type KE2State: FromBytes + ToBytes + ZeroizeOnDrop + Clone;
|
||||
type KE1Message: FromBytes + ToBytes + ZeroizeOnDrop + Clone;
|
||||
type KE2Message: FromBytes + ToBytes + ZeroizeOnDrop + Clone;
|
||||
type KE3Message: FromBytes + ToBytes + ZeroizeOnDrop + Clone;
|
||||
type KE1State: Deserialize + Serialize + ZeroizeOnDrop + Clone;
|
||||
type KE2State: Deserialize + Serialize + ZeroizeOnDrop + Clone;
|
||||
type KE1Message: Deserialize + Serialize + ZeroizeOnDrop + Clone;
|
||||
type KE2Message: Deserialize + Serialize + ZeroizeOnDrop + Clone;
|
||||
type KE3Message: Deserialize + Serialize + ZeroizeOnDrop + Clone;
|
||||
|
||||
fn generate_ke1<R: RngCore + CryptoRng>(
|
||||
rng: &mut R,
|
||||
@@ -88,23 +66,45 @@ where
|
||||
) -> Result<Output<D>, ProtocolError>;
|
||||
}
|
||||
|
||||
pub trait FromBytes: Sized {
|
||||
fn from_bytes(input: &[u8]) -> Result<Self, ProtocolError>;
|
||||
pub trait Deserialize: Sized {
|
||||
fn deserialize(input: &[u8]) -> Result<Self, ProtocolError>;
|
||||
}
|
||||
|
||||
pub trait ToBytes {
|
||||
pub trait Serialize {
|
||||
type Len: ArrayLength<u8>;
|
||||
|
||||
fn to_bytes(&self) -> GenericArray<u8, Self::Len>;
|
||||
fn serialize(&self) -> GenericArray<u8, Self::Len>;
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub type GenerateKe2Result<K, D, G> = (
|
||||
<K as KeyExchange<D, G>>::KE2State,
|
||||
<K as KeyExchange<D, G>>::KE2Message,
|
||||
);
|
||||
#[cfg(test)]
|
||||
pub type GenerateKe2Result<K, D, G> = (
|
||||
<K as KeyExchange<D, G>>::KE2State,
|
||||
<K as KeyExchange<D, G>>::KE2Message,
|
||||
Output<D>,
|
||||
Output<D>,
|
||||
);
|
||||
#[cfg(not(test))]
|
||||
pub type GenerateKe3Result<K, D, G> = (Output<D>, <K as KeyExchange<D, G>>::KE3Message);
|
||||
#[cfg(test)]
|
||||
pub type GenerateKe3Result<K, D, G> = (
|
||||
Output<D>,
|
||||
<K as KeyExchange<D, G>>::KE3Message,
|
||||
Output<D>,
|
||||
Output<D>,
|
||||
);
|
||||
|
||||
pub type Ke1StateLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1State as ToBytes>::Len;
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1State as Serialize>::Len;
|
||||
pub type Ke1MessageLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1Message as ToBytes>::Len;
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE1Message as Serialize>::Len;
|
||||
pub type Ke2StateLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2State as ToBytes>::Len;
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2State as Serialize>::Len;
|
||||
pub type Ke2MessageLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2Message as ToBytes>::Len;
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE2Message as Serialize>::Len;
|
||||
pub type Ke3MessageLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE3Message as ToBytes>::Len;
|
||||
<<CS::KeyExchange as KeyExchange<OprfHash<CS>, CS::KeGroup>>::KE3Message as Serialize>::Len;
|
||||
|
||||
Reference in New Issue
Block a user