Struct elliptic_curve::ecdh::SharedSecret
source · [−]pub struct SharedSecret<C: Curve> { /* private fields */ }
ecdh
only.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
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
impl<C: Curve> From<GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>> for SharedSecret<C>
impl<C: Curve> From<GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>> for SharedSecret<C>
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
.