INNER CODE UNIT · Rust
create_check_code
matrix-org/vodozemac · src/ecies/mod.rs:325
fn create_check_code(
shared_secret: &SharedSecret,
our_public_key: Curve25519PublicKey,
their_public_key: Curve25519PublicKey,
info: &str,
role: Role,
) -> CheckCode {
let mut bytes = [0u8; 2];
let kdf: Hkdf<Sha512> = Hkdf::new(None, shared_secret.as_bytes());
let info = Self::get_check_code_info(info, role, our_public_key, their_public_key);
#[allow(clippy::expect_used)]
kdf.expand(info.as_bytes(), bytes.as_mut_slice()).expect(
"We should be able to expand the 32-byte long shared secret into a 32 byte key.",
);
CheckCode { bytes }