Files
opaque-vx/src/key_exchange/group/mod.rs
T

44 lines
1.5 KiB
Rust
Raw Normal View History

2021-10-25 02:54:32 -07:00
// Copyright (c) Facebook, Inc. and its affiliates.
//
2021-12-03 14:38:11 -08:00
// This source code is licensed under both the MIT license found in the
// LICENSE-MIT file in the root directory of this source tree and the Apache
// License, Version 2.0 found in the LICENSE-APACHE file in the root directory
// of this source tree.
2021-10-25 02:54:32 -07:00
//! Includes the KeGroup trait and definitions for the
//! key exchange groups
use crate::errors::InternalError;
use generic_array::{ArrayLength, GenericArray};
use rand::{CryptoRng, RngCore};
/// A group representation for use in the key exchange
pub trait KeGroup: Sized + Clone {
/// Length of the public key
type PkLen: ArrayLength<u8> + 'static;
/// Length of the secret key
type SkLen: ArrayLength<u8> + 'static;
/// Return a public key from its fixed-length bytes representation
fn from_pk_slice(element_bits: &GenericArray<u8, Self::PkLen>) -> Result<Self, InternalError>;
/// Generate a random secret key
fn random_sk<R: RngCore + CryptoRng>(rng: &mut R) -> GenericArray<u8, Self::SkLen>;
/// Return a public key from its secret key
fn public_key(sk: &GenericArray<u8, Self::SkLen>) -> Self;
/// Serializes `self`
fn to_arr(&self) -> GenericArray<u8, Self::PkLen>;
/// Diffie-Hellman key exchange
fn diffie_hellman(&self, sk: &GenericArray<u8, Self::SkLen>) -> GenericArray<u8, Self::PkLen>;
}
#[cfg(feature = "p256")]
pub mod p256;
2022-01-04 00:50:40 +01:00
#[cfg(feature = "ristretto255")]
2021-10-25 02:54:32 -07:00
pub mod ristretto255;
2022-01-04 00:50:40 +01:00
#[cfg(feature = "x25519")]
2021-10-25 02:54:32 -07:00
pub mod x25519;