Skip to content

Commit

Permalink
Private Key encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Nov 21, 2024
1 parent 49efbc8 commit beaad0b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libcrux-kem/src/kem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,18 @@ pub struct X25519MlKem768Draft00PrivateKey {
impl X25519MlKem768Draft00PrivateKey {
pub fn decode(bytes: &[u8]) -> Result<Self, Error> {
Ok(Self {
mlkem: bytes[32..]
mlkem: bytes[..2400]
.try_into()
.map_err(|_| Error::InvalidPrivateKey)?,
x25519: bytes[..32]
x25519: bytes[2400..]
.try_into()
.map_err(|_| Error::InvalidPrivateKey)?,
})
}

pub fn encode(&self) -> Vec<u8> {
let mut out = self.x25519.0.to_vec();
out.extend_from_slice(self.mlkem.as_ref());
let mut out = self.mlkem.as_ref().to_vec();
out.extend_from_slice(&self.x25519.0);
out
}
}
Expand Down

0 comments on commit beaad0b

Please sign in to comment.