diff options
author | Satya Rohith <me@satyarohith.com> | 2024-03-18 13:20:10 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 13:20:10 +0530 |
commit | becdad531f2b56684133b3b7ea25169c7102f765 (patch) | |
tree | e03e3e411fdc888ccd2200bab9aa9721b34c92dc /tests/unit_node/crypto/crypto_key_test.ts | |
parent | 9c5ddf7c69f0d3ddaa93b194f0020944569e0e3e (diff) |
fix(ext/node): support public key point encoding in ECDH.generateKeys() (#22976)
Towards https://github.com/denoland/deno/issues/22921
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'tests/unit_node/crypto/crypto_key_test.ts')
-rw-r--r-- | tests/unit_node/crypto/crypto_key_test.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/unit_node/crypto/crypto_key_test.ts b/tests/unit_node/crypto/crypto_key_test.ts index bcb47b5a7..5fa36bd11 100644 --- a/tests/unit_node/crypto/crypto_key_test.ts +++ b/tests/unit_node/crypto/crypto_key_test.ts @@ -2,6 +2,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import { + createECDH, createHmac, createPrivateKey, createPublicKey, @@ -313,3 +314,12 @@ Deno.test("createPublicKey SPKI for DH", async function () { assertEquals(pubKey.asymmetricKeyType, "ec"); assertEquals(privKey.asymmetricKeyType, "ec"); }); + +Deno.test("ECDH generateKeys compressed", function () { + const ecdh = createECDH("secp256k1"); + const publicKey = ecdh.generateKeys("binary", "compressed"); + assertEquals(publicKey.length, 33); + + const uncompressedKey = ecdh.generateKeys("binary"); + assertEquals(uncompressedKey.length, 65); +}); |