0

This is for encryption from documentation of getStream. https://getstream.io/chat/docs/sdk/flutter/guides/end_to_end_chat_encryption/#dependencies

I am using webcrypto: ^0.5.2 as mentioned in the documentation.

Future<JsonWebKeyPair> generateKeys() async {
  final keyPair = await EcdhPrivateKey.generateKey(EllipticCurve.p256);
  final publicKeyJwk = await keyPair.publicKey.exportJsonWebKey();
  final privateKeyJwk = await keyPair.privateKey.exportJsonWebKey();

  return JsonWebKeyPair(
    privateKey: json.encode(privateKeyJwk),
    publicKey: json.encode(publicKeyJwk),
  );
}

I am getting error "package:webcrypto failed to attached finalizer" in the generateKey function

I have tried changing the version of webcrypto but I am still getting the error.

  • Could you share a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the issue? I've tried to run your `generateKeys` function, but it works fine in a newly created project. Here are the generated keys i get: privateKeyJwk: `{kty: EC, crv: P-256, x: tjUHpl0oP9-DUz_MSjWpCdTCuFPH_0BBa-bI6iKE8go, y: umFACTQgnsFpVkd6ZNuCj-Q_cBYviIz1trhieCyMKIE, d: ChOuuqGV9N0kwOQh9m_HI4zSBVBEdzlcmGWUkpRsOgM}` publicKeyJwk: `{kty: EC, crv: P-256, x: tjUHpl0oP9-DUz_MSjWpCdTCuFPH_0BBa-bI6iKE8go, y: umFACTQgnsFpVkd6ZNuCj-Q_cBYviIz1trhieCyMKIE}` – Zoltán Dec 12 '22 at 10:46

1 Answers1

0

I was using flutter version 3.3.2 but I used webcrypto 0.5.2. Updated the version of webcrypto to 0.5.3(which has migration to flutter 3). After updating the version it worked for me.

zorro
  • 101
  • 1
  • 10