diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-03-21 14:11:54 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-21 14:11:54 +0530 |
commit | 1f60b8af97b15cb8e33f68c44f602cf69d79bd7a (patch) | |
tree | b7ab11749fc4e20a9b4589ba2b97bd64991bb9f0 /tests | |
parent | 210f2911ce3f498524c0354e8f60d62e3dbc39ed (diff) |
fix(ext/node): ECDH.publicKey() point encoding (#23013)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit_node/crypto/crypto_key_test.ts | 13 |
1 files changed, 13 insertions, 0 deletions
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); + } +}); |