mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
From<[u8; 32]> for Ephemeral Public, fix to benches
This commit is contained in:
parent
8730bfbba6
commit
ff0e1f286b
2 changed files with 8 additions and 1 deletions
|
|
@ -30,7 +30,6 @@ fn bench_diffie_hellman(c: &mut Criterion) {
|
|||
let bob_public: EphemeralPublic = EphemeralPublic::from(&bob_secret);
|
||||
|
||||
c.bench_function("diffie_hellman", move |b| {
|
||||
let alice_secret: EphemeralSecret = EphemeralSecret::new(&mut csprng);
|
||||
b.iter_with_setup(
|
||||
|| EphemeralSecret::new(&mut csprng),
|
||||
|alice_secret| EphemeralSecret::diffie_hellman(alice_secret, &bob_public),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,14 @@ use rand_core::CryptoRng;
|
|||
#[repr(C)]
|
||||
pub struct EphemeralPublic(pub (crate) MontgomeryPoint);
|
||||
|
||||
impl From<[u8; 32]> for EphemeralPublic {
|
||||
/// Given a byte array, construct an x25519 `EphemeralPublic` key
|
||||
fn from(bytes: [u8; 32]) -> EphemeralPublic {
|
||||
EphemeralPublic(MontgomeryPoint(bytes))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// A DH ephemeral secret key.
|
||||
#[repr(C)]
|
||||
#[derive(Default)] // we derive Default in order to use the clear() method in Drop
|
||||
|
|
|
|||
Loading…
Reference in a new issue