deriveSharedKeyFactory function

Function deriveSharedKeyFactory(
  1. String info,
  2. Function cryptoHash
)

Implementation

Function deriveSharedKeyFactory(String info, Function cryptoHash) {
  final deriveSharedSecret = deriveSharedSecretFactory(cryptoHash);
  return (Uint8List privateKeyBytes, ct.PublicKey otherPublicKey) {
    final sharedSecret = deriveSharedSecret(privateKeyBytes, otherPublicKey);
    var hkdf = pointy.KeyDerivator('SHA-256/HKDF');
    var hkdfParams = pointy.HkdfParameters(
        sharedSecret, 32, Uint8List(32), utf8ToBytes(info));
    hkdf.init(hkdfParams);
    var key = hkdf.process(Uint8List(0));
    return ct.SharedKey256(key);
  };
}