From becdad531f2b56684133b3b7ea25169c7102f765 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Mon, 18 Mar 2024 13:20:10 +0530 Subject: 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 --- tests/unit_node/crypto/crypto_key_test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') 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); +}); -- cgit v1.2.3