Created
June 25, 2021 06:57
-
-
Save pinkeshdarji/83f1d0281eb9f3be500649a37370ae35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> _deriveKey() async { | |
//1. Alice's public key | |
Map<String, dynamic> publicjwk = json.decode( | |
'{"kty": "EC", "crv": "P-256", "x": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "y": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}'); | |
EcdhPublicKey ecdhPublicKey = | |
await EcdhPublicKey. | |
(publicjwk, EllipticCurve.p256); | |
//2. Bob's private key | |
Map<String, dynamic> privatejwk = json.decode( | |
'{"kty": "EC", "crv": "P-256", "x": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "y": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "d": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}'); | |
EcdhPrivateKey ecdhPrivateKey = | |
await EcdhPrivateKey. | |
(privatejwk, EllipticCurve.p256); | |
//3. Generating cryptokey called deriveBits | |
Uint8List derivedBits = await ecdhPrivateKey.deriveBits(256, ecdhPublicKey); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment