Crate edx

Source
Expand description

§ECDH key exchange using Ed25519 derived keys

use {
	ed25519_dalek::{SigningKey, SECRET_KEY_LENGTH},
	edx::{DeriveFactor, EdXchangeable, DERIVE_FACTOR_LENGTH},
};

let d_factor = DeriveFactor::from_bytes([42; DERIVE_FACTOR_LENGTH]);

let alice_sign = SigningKey::from_bytes(&[114; SECRET_KEY_LENGTH]);
let alice_verify = alice_sign.verifying_key();

let bob_sign = SigningKey::from_bytes(&[51; SECRET_KEY_LENGTH]);
let bob_verify = bob_sign.verifying_key();

let alice_kex_secret = alice_sign.edxchange(&bob_verify, &d_factor);
let bob_kex_secret = bob_sign.edxchange(&alice_verify, &d_factor);
assert_eq!(alice_kex_secret.as_bytes(), bob_kex_secret.as_bytes());

Structs§

DeriveFactor
Derive factor used in key derivation. SHOULD be unique for each message. MUST NOT be all zero, otherwise it’s just the base key, and meaningless.
EdXPoint
Convenience wrapper for an EdwardsPoint, with From impls for key types in various libraries.
EdXScalar
Wrapper for a Scalar ensuring it’s clamped and reduced for the key exchange, with From impls for key types in various libraries.
SharedSecret
Result of a ECDH key exchange.

Constants§

DERIVE_FACTOR_LENGTH

Traits§

EdXchangeable
Trait for types holding secret scalar, which could be derived thus participate in key exchange.