From 1f60b8af97b15cb8e33f68c44f602cf69d79bd7a Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Thu, 21 Mar 2024 14:11:54 +0530 Subject: fix(ext/node): ECDH.publicKey() point encoding (#23013) --- tests/unit_node/crypto/crypto_key_test.ts | 13 +++++++++++++ 1 file changed, 13 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 de941da88..ef154fc35 100644 --- a/tests/unit_node/crypto/crypto_key_test.ts +++ b/tests/unit_node/crypto/crypto_key_test.ts @@ -341,3 +341,16 @@ Deno.test("ECDH generateKeys compressed", function () { const uncompressedKey = ecdh.generateKeys("binary"); assertEquals(uncompressedKey.length, 65); }); + +Deno.test("ECDH getPublicKey compressed", function () { + const ecdh = createECDH("secp256k1"); + for (const format of ["compressed", "uncompressed"] as const) { + ecdh.generateKeys("binary", format); + + const compressedKey = ecdh.getPublicKey("binary", "compressed"); + assertEquals(compressedKey.length, 33); + + const uncompressedKey = ecdh.getPublicKey("binary"); + assertEquals(uncompressedKey.length, 65); + } +}); -- cgit v1.2.3