File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,28 @@ abstract class EcdhPrivateKey {
32
32
return impl.ecdhPrivateKey_importJsonWebKey (jwk, curve);
33
33
}
34
34
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
+ ///
35
57
static Future <KeyPair <EcdhPrivateKey , EcdhPublicKey >> generateKey (
36
58
EllipticCurve curve,
37
59
) {
You can’t perform that action at this time.
0 commit comments