Skip to content

Commit

Permalink
docs: document exportPkcs8Ket in EcdhPrivateKey
Browse files Browse the repository at this point in the history
  • Loading branch information
HamdaanAliQuatil committed May 31, 2024
1 parent b295d8d commit 6ca2557
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/src/webcrypto/webcrypto.ecdh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,25 @@ abstract class EcdhPrivateKey {
// https://tools.ietf.org/html/rfc6090#appendix-B
Future<Uint8List> deriveBits(int length, EcdhPublicKey publicKey);

/// Export the [EcdhPrivateKey] as a [PKCS #8][1] key.
///
/// Returns private key as a list of bytes.
///
/// **Example**
/// ```dart
/// import 'package:pem/pem.dart';
/// import 'package:webcrypto/webcrypto.dart';
///
/// Future<void> main() async {
/// // Alice generates a key-pair
/// final kpA = await EcdhPrivateKey.generateKey(EllipticCurve.p256);
///
/// // Export the private key (print it in same format as it was given).
/// final exportedPkcs8Key = await kpA.privateKey.exportPkcs8Key();
/// print(PemCodec(PemLabel.privateKey).encode(exportedPkcs8Key));
/// }
/// ```
/// [1]: https://datatracker.ietf.org/doc/html/rfc5208
Future<Uint8List> exportPkcs8Key();

Future<Map<String, dynamic>> exportJsonWebKey();
Expand Down

0 comments on commit 6ca2557

Please sign in to comment.