deriveSymKey method

  1. @override
Future<String> deriveSymKey(
  1. String privKeyA,
  2. String pubKeyB
)
override

Implementation

@override
Future<String> deriveSymKey(String privKeyA, String pubKeyB) async {
  final Uint8List sharedKey1 = x.X25519(
    hex.decode(privKeyA),
    hex.decode(pubKeyB),
  );

  Uint8List out = Uint8List(KEY_LENGTH);

  final HKDFKeyDerivator hkdf = HKDFKeyDerivator(SHA256Digest());
  final HkdfParameters params = HkdfParameters(
    sharedKey1,
    KEY_LENGTH,
  );
  hkdf.init(params);
  // final pc.KeyParameter keyParam = hkdf.extract(null, sharedKey1);
  hkdf.deriveKey(null, 0, out, 0);
  return hex.encode(out);
}