File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -301,5 +301,35 @@ abstract class EcdhPublicKey {
301
301
/// See compatibility section in [EcdhPublicKey.importSpkiKey] .
302
302
Future <Uint8List > exportSpkiKey ();
303
303
304
+ /// Export the [EcdhPublicKey] as a [JSON Web Key][1] .
305
+ ///
306
+ /// {@macro exportJsonWebKey:returns}
307
+ ///
308
+ /// **Example**
309
+ /// ```dart
310
+ /// import 'dart:convert';
311
+ /// import 'package:webcrypto/webcrypto.dart';
312
+ ///
313
+ /// // Public JSON Web Key data.
314
+ /// final jwk = {
315
+ /// 'kty': 'EC',
316
+ /// 'crv': 'P-256',
317
+ /// 'x': 'kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI',
318
+ /// 'y': 'djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE'
319
+ /// };
320
+ ///
321
+ /// Future<void> main() async {
322
+ /// // Alice generates a key-pair
323
+ /// final kpA = await EcdhPublicKey.importJsonWebKey(jwk, EllipticCurve.p256);
324
+ ///
325
+ /// // Export the public key as a JSON Web Key.
326
+ /// final exportedPublicKey = await kpA.exportJsonWebKey();
327
+ ///
328
+ /// // The Map returned by `exportJsonWebKey()` can be converted to JSON with
329
+ /// // `jsonEncode` from `dart:convert`.
330
+ /// print(jsonEncode(exportedPublicKey));
331
+ /// }
332
+ /// ```
333
+ /// [1] : https://www.rfc-editor.org/rfc/rfc7518.html#section-6.2
304
334
Future <Map <String , dynamic >> exportJsonWebKey ();
305
335
}
You can’t perform that action at this time.
0 commit comments