pub struct SharedSecret<C: Curve> { /* private fields */ }Expand description
Shared secret value computed via ECDH key agreement.
This value contains the raw serialized x-coordinate of the elliptic curve point computed from a Diffie-Hellman exchange.
§⚠️ WARNING: NOT UNIFORMLY RANDOM! ⚠️
This value is not uniformly random and should not be used directly as a cryptographic key for anything which requires that property (e.g. symmetric ciphers).
Instead, the resulting value should be used as input to a Key Derivation Function (KDF) or cryptographic hash function to produce a symmetric key.
Implementations§
Sourcepub fn as_bytes(&self) -> &FieldBytes<C>
pub fn as_bytes(&self) -> &FieldBytes<C>
Shared secret value, serialized as bytes.
As noted in the comments for this struct, this value is non-uniform and should not be used directly as a symmetric encryption key, but instead as input to a KDF (or failing that, a hash function) used to produce a symmetric key.
Trait Implementations§
Source§fn from(secret_bytes: FieldBytes<C>) -> Self
fn from(secret_bytes: FieldBytes<C>) -> Self
NOTE: this impl is intended to be used by curve implementations to
instantiate a SharedSecret value from their respective
AffinePoint type.
Curve implementations should provide the field element representing
the affine x-coordinate as secret_bytes.