wcDeriveSymKey function

String wcDeriveSymKey(
  1. String privKeyHex,
  2. String pubKeyHex
)

Derive the shared symmetric key from our private key and the peer public key. Returns the 32-byte symKey as hex. symKey = HKDF-SHA256(X25519(priv, pub)).

Implementation

String wcDeriveSymKey(String privKeyHex, String pubKeyHex) {
  final shared = x25519(hexDecode(privKeyHex), hexDecode(pubKeyHex));
  final sym = hkdfSha256(shared, length: _keyLength);
  return hexEncode(sym);
}