From 80f78b751bd6fc4fd58627fa59e7764d19f31bea Mon Sep 17 00:00:00 2001 From: HamdaanAliQuatil Date: Thu, 30 May 2024 12:47:43 +0530 Subject: [PATCH 1/2] docs: document deriveBits in EcdhPrivateKey --- lib/src/webcrypto/webcrypto.ecdh.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/src/webcrypto/webcrypto.ecdh.dart b/lib/src/webcrypto/webcrypto.ecdh.dart index 45932d8d..6ab3f636 100644 --- a/lib/src/webcrypto/webcrypto.ecdh.dart +++ b/lib/src/webcrypto/webcrypto.ecdh.dart @@ -38,6 +38,19 @@ abstract class EcdhPrivateKey { return impl.ecdhPrivateKey_generateKey(curve); } + /// Derives a shared secret from two ECDH key pairs using the private key from one pair + /// and the public key from another. + /// + /// The shared secret is identical whether using A's private key and B's public key, + /// or B's private key and A's public key, enabling secure key exchange between the + /// two parties. + /// + /// [length] specifies the length of the derived secret in bits. + /// [publicKey] is [EcdhPublicKey] from the other party's ECDH key pair. + /// + /// Returns a [Uint8List] containing the derived shared secret. + /// + /// {@macro EcdhPrivateKey:example} // Note some webcrypto implementations (chrome, not firefox) supports passing // null for length (in this primitive). However, you can always know the right // length from the curve. Note p512 can provide up to: 528 bits!!! From 303a6c32583c4b7a45f41274d3f97187419921cb Mon Sep 17 00:00:00 2001 From: HamdaanAliQuatil <96776914+HamdaanAliQuatil@users.noreply.github.com> Date: Thu, 30 May 2024 18:51:51 +0530 Subject: [PATCH 2/2] Update lib/src/webcrypto/webcrypto.ecdh.dart Co-authored-by: Jonas Finnemann Jensen --- lib/src/webcrypto/webcrypto.ecdh.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/webcrypto/webcrypto.ecdh.dart b/lib/src/webcrypto/webcrypto.ecdh.dart index 6ab3f636..f6c6cce4 100644 --- a/lib/src/webcrypto/webcrypto.ecdh.dart +++ b/lib/src/webcrypto/webcrypto.ecdh.dart @@ -38,7 +38,7 @@ abstract class EcdhPrivateKey { return impl.ecdhPrivateKey_generateKey(curve); } - /// Derives a shared secret from two ECDH key pairs using the private key from one pair + /// Derive a shared secret from two ECDH key pairs using the private key from one pair /// and the public key from another. /// /// The shared secret is identical whether using A's private key and B's public key,