Skip to content

Commit 2b1d99e

Browse files
Document generateKey in the EcdhPrivateKey Class (#123)
* docs: document generateKey in EcdhPrivateKey * docs: remove enum details
1 parent b3518ba commit 2b1d99e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/src/webcrypto/webcrypto.ecdh.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,28 @@ abstract class EcdhPrivateKey {
3232
return impl.ecdhPrivateKey_importJsonWebKey(jwk, curve);
3333
}
3434

35+
/// Generate a new [EcdhPrivateKey] and [EcdhPublicKey] pair.
36+
///
37+
/// The [curve] parameter specifies the curve to use for the key pair.
38+
///
39+
/// **Example**
40+
/// ```dart
41+
/// import 'package:webcrypto/webcrypto.dart';
42+
///
43+
/// Future<void> main() async {
44+
/// // Generate a new key pair using the P-256 curve.
45+
/// final keyPair = await EcdhPrivateKey.generateKey(EllipticCurve.p256);
46+
///
47+
/// // Export the private key.
48+
/// final exportedPrivateKey = await keyPair.privateKey.exportJsonWebKey();
49+
/// print(exportedPrivateKey);
50+
///
51+
/// // Export the public key.
52+
/// final exportedPublicKey = await keyPair.publicKey.exportJsonWebKey();
53+
/// print(exportedPublicKey);
54+
/// }
55+
/// ```
56+
///
3557
static Future<KeyPair<EcdhPrivateKey, EcdhPublicKey>> generateKey(
3658
EllipticCurve curve,
3759
) {

0 commit comments

Comments
 (0)