EcdhKeyDerivation class ECDH

Performs ECDH key agreement and key derivation.

Use deriveKey to produce raw derived bytes via HKDF, or deriveAesKey to get a FortisAesKey directly.

For raw shared secret bytes (without HKDF), use deriveSharedSecret.

final pair = await Fortis.ecdh().generateKeyPair();
final theirPublicKey = (await Fortis.ecdh().generateKeyPair()).publicKey;

final derivation = Fortis.ecdh()
    .curve(EcdhCurve.p256)
    .keyDerivation(pair.privateKey);

// Derive raw key bytes
final keyBytes = derivation.deriveKey(theirPublicKey);

// Derive an AES key directly
final aesKey = derivation.deriveAesKey(theirPublicKey);

// Or get the raw shared secret
final secret = derivation.deriveSharedSecret(theirPublicKey);

See also:

Constructors

EcdhKeyDerivation({required FortisEcdhPrivateKey privateKey, int keySize = 256})
Creates an EcdhKeyDerivation with the given privateKey and optional keySize in bits (default 256).

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

deriveAesKey(FortisEcdhPublicKey publicKey, {Uint8List? salt, Uint8List? info}) FortisAesKey
Derives a ready-to-use FortisAesKey from the ECDH shared secret with publicKey.
deriveKey(FortisEcdhPublicKey publicKey, {Uint8List? salt, Uint8List? info}) Uint8List
Derives raw key bytes from the ECDH shared secret with publicKey.
deriveSharedSecret(FortisEcdhPublicKey publicKey) Uint8List
Computes the raw ECDH shared secret with the given publicKey.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

hkdf(Uint8List sharedSecret, {int keySize = 256, Uint8List? salt, Uint8List? info}) Uint8List
Derives key bytes from an arbitrary shared secret using HKDF-SHA256 (RFC 5869).
hkdfDeriveAesKey(Uint8List sharedSecret, {int keySize = 256, Uint8List? salt, Uint8List? info}) FortisAesKey
Derives a FortisAesKey from an arbitrary shared secret using HKDF-SHA256.