Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ debug = true

[patch.crates-io]
ml-kem = { path = "./ml-kem" }

kem = { git = "https://github.com/RustCrypto/traits" }
19 changes: 18 additions & 1 deletion ml-kem/src/kem.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::convert::Infallible;
use core::marker::PhantomData;
use hybrid_array::typenum::U32;
use hybrid_array::typenum::{U32, U64};
use rand_core::{CryptoRng, TryCryptoRng};
use subtle::{ConditionallySelectable, ConstantTimeEq};

Expand Down Expand Up @@ -98,6 +98,23 @@ where
}
}

impl<P> ::kem::KeySizeUser for DecapsulationKey<P>
where
P: KemParams,
{
type KeySize = U64;
}

impl<P> ::kem::KeyInit for DecapsulationKey<P>
where
P: KemParams,
{
#[inline]
fn new(seed: &Seed) -> Self {
Self::from_seed(*seed)
}
}

impl<P> ::kem::Decapsulate<EncodedCiphertext<P>, SharedKey> for DecapsulationKey<P>
where
P: KemParams,
Expand Down
12 changes: 11 additions & 1 deletion x-wing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
pub use kem::{self, Decapsulate, Encapsulate};

use core::convert::Infallible;
use ml_kem::array::ArrayN;
use ml_kem::array::{ArrayN, typenum::consts::U32};
use ml_kem::{B32, EncodedSizeUser, KemCore, MlKem768, MlKem768Params};
use rand_core::{CryptoRng, TryCryptoRng};
#[cfg(feature = "os_rng")]
Expand Down Expand Up @@ -145,6 +145,16 @@ impl Decapsulate<Ciphertext, SharedSecret> for DecapsulationKey {
}
}

impl ::kem::KeySizeUser for DecapsulationKey {
type KeySize = U32;
}

impl ::kem::KeyInit for DecapsulationKey {
fn new(key: &ArrayN<u8, 32>) -> Self {
Self { sk: key.0 }
}
}

impl DecapsulationKey {
/// Generate a new `DecapsulationKey` using `OsRng`.
#[cfg(feature = "os_rng")]
Expand Down