Voprf update (#255)
* Update to latest voprf * Upgrade to Rust edition 2021 * Fix Clippy * Remove all allocations * Remove unnecessary `allow(type_alias_bounds)` * Make all serialization infallible * Remove self-dependency * Update rustyline
This commit is contained in:
+18
-18
@@ -5,6 +5,7 @@
|
||||
// License, Version 2.0 found in the LICENSE-APACHE file in the root directory
|
||||
// of this source tree.
|
||||
|
||||
use crate::hash::ProxyHash;
|
||||
use crate::key_exchange::group::KeGroup;
|
||||
use crate::{
|
||||
ciphersuite::CipherSuite,
|
||||
@@ -12,7 +13,9 @@ use crate::{
|
||||
hash::Hash,
|
||||
keypair::{PrivateKey, PublicKey, SecretKey},
|
||||
};
|
||||
use digest::Digest;
|
||||
use digest::core_api::BlockSizeUser;
|
||||
use digest::Output;
|
||||
use generic_array::typenum::{IsLess, Le, NonZero, U256};
|
||||
use generic_array::{ArrayLength, GenericArray};
|
||||
use rand::{CryptoRng, RngCore};
|
||||
use zeroize::Zeroize;
|
||||
@@ -26,23 +29,25 @@ pub type GenerateKe2Result<K, D, G> = (
|
||||
pub type GenerateKe2Result<K, D, G> = (
|
||||
<K as KeyExchange<D, G>>::KE2State,
|
||||
<K as KeyExchange<D, G>>::KE2Message,
|
||||
GenericArray<u8, <D as Digest>::OutputSize>,
|
||||
GenericArray<u8, <D as Digest>::OutputSize>,
|
||||
Output<D>,
|
||||
Output<D>,
|
||||
);
|
||||
#[cfg(not(test))]
|
||||
pub type GenerateKe3Result<K, D, G> = (
|
||||
GenericArray<u8, <D as Digest>::OutputSize>,
|
||||
<K as KeyExchange<D, G>>::KE3Message,
|
||||
);
|
||||
pub type GenerateKe3Result<K, D, G> = (Output<D>, <K as KeyExchange<D, G>>::KE3Message);
|
||||
#[cfg(test)]
|
||||
pub type GenerateKe3Result<K, D, G> = (
|
||||
GenericArray<u8, <D as Digest>::OutputSize>,
|
||||
Output<D>,
|
||||
<K as KeyExchange<D, G>>::KE3Message,
|
||||
GenericArray<u8, <D as Digest>::OutputSize>,
|
||||
GenericArray<u8, <D as Digest>::OutputSize>,
|
||||
Output<D>,
|
||||
Output<D>,
|
||||
);
|
||||
|
||||
pub trait KeyExchange<D: Hash, G: KeGroup> {
|
||||
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 + Zeroize + Clone;
|
||||
type KE2State: FromBytes + ToBytes + Zeroize + Clone;
|
||||
type KE1Message: FromBytes + ToBytes + Zeroize + Clone;
|
||||
@@ -83,7 +88,7 @@ pub trait KeyExchange<D: Hash, G: KeGroup> {
|
||||
fn finish_ke(
|
||||
ke3_message: Self::KE3Message,
|
||||
ke2_state: &Self::KE2State,
|
||||
) -> Result<GenericArray<u8, D::OutputSize>, ProtocolError>;
|
||||
) -> Result<Output<D>, ProtocolError>;
|
||||
|
||||
fn ke2_message_size() -> usize;
|
||||
}
|
||||
@@ -98,19 +103,14 @@ pub trait ToBytes {
|
||||
fn to_bytes(&self) -> GenericArray<u8, Self::Len>;
|
||||
}
|
||||
|
||||
#[allow(dead_code, type_alias_bounds)]
|
||||
#[allow(dead_code)]
|
||||
pub type Ke1StateLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<CS::Hash, CS::KeGroup>>::KE1State as ToBytes>::Len;
|
||||
#[allow(type_alias_bounds)]
|
||||
pub type Ke1MessageLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<CS::Hash, CS::KeGroup>>::KE1Message as ToBytes>::Len;
|
||||
#[allow(type_alias_bounds)]
|
||||
#[allow(type_alias_bounds)]
|
||||
pub type Ke2StateLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<CS::Hash, CS::KeGroup>>::KE2State as ToBytes>::Len;
|
||||
#[allow(type_alias_bounds)]
|
||||
pub type Ke2MessageLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<CS::Hash, CS::KeGroup>>::KE2Message as ToBytes>::Len;
|
||||
#[allow(type_alias_bounds)]
|
||||
pub type Ke3MessageLen<CS: CipherSuite> =
|
||||
<<CS::KeyExchange as KeyExchange<CS::Hash, CS::KeGroup>>::KE3Message as ToBytes>::Len;
|
||||
|
||||
Reference in New Issue
Block a user