Skip to content

Commit

Permalink
fix ci error
Browse files Browse the repository at this point in the history
  • Loading branch information
keks committed Nov 14, 2024
1 parent 3c5be34 commit f0f3d0e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
11 changes: 5 additions & 6 deletions curve25519/src/impl_hacl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ use super::*;
pub struct HaclCurve25519;

impl Curve25519 for HaclCurve25519 {
// the hacl::ecdh function requires all parameters to be 32 byte long, which we enforce using
// The hacl::ecdh function requires all parameters to be 32 byte long, which we enforce using
// types.
fn secret_to_public(pk: &mut [u8; PK_LEN], sk: &[u8; SK_LEN]) {
crate::hacl::secret_to_public(pk, sk)
}

// the hacl::ecdh function requires all parameters to be 32 byte long, which we enforce using
// The hacl::ecdh function requires all parameters to be 32 byte long, which we enforce using
// types.
fn ecdh(out: &mut [u8; SHK_LEN], pk: &[u8; PK_LEN], sk: &[u8; SK_LEN]) -> Result<(), Error> {
if crate::hacl::ecdh(out, sk, pk) {
Ok(())
} else {
Err(Error)
match crate::hacl::ecdh(out, sk, pk) {
true => Ok(()),
false => Err(Error),
}
}
}
7 changes: 3 additions & 4 deletions libcrux-ecdh/src/hacl/curve25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ pub fn ecdh(
public_key: impl AsRef<[u8; 32]>,
) -> Result<[u8; 32], Error> {
let mut shared = [0u8; 32];
match libcrux_curve25519::ecdh(&mut shared, private_key.as_ref(), public_key.as_ref()) {
Ok(_) => Ok(shared),
Err(_) => Err(Error::InvalidInput),
}
libcrux_curve25519::ecdh(&mut shared, public_key.as_ref(), private_key.as_ref())
.map(|_| shared)
.map_err(|_| Error::InvalidInput)
}

/// Compute the public key for the provided `private_key` (scalar multiplication
Expand Down
8 changes: 2 additions & 6 deletions libcrux-ecdh/tests/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn wycheproof() {
"public key = 57896044618658097711785492504343953926634992332820282019728792003956564819968" => false,
"public key = 57896044618658097711785492504343953926634992332820282019728792003956564819969" => false,
"special case public key" => {
if (test.flags.contains(&"Twist".to_owned()) && test.tcId != 154)
(test.flags.contains(&"Twist".to_owned()) && test.tcId != 154)
|| test.tcId == 120
|| test.tcId == 122
|| test.tcId == 123
Expand All @@ -102,11 +102,7 @@ fn wycheproof() {
|| test.tcId == 150
|| test.tcId == 151
|| test.tcId == 152
|| test.tcId == 153 {
true
} else {
false
}
|| test.tcId == 153
},
"D = 0 in multiplication by 2" => false,
_ => valid,
Expand Down

0 comments on commit f0f3d0e

Please sign in to comment.