summaryrefslogtreecommitdiff
path: root/tests/unit_node/crypto/crypto_key_test.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-03-21 14:11:54 +0530
committerGitHub <noreply@github.com>2024-03-21 14:11:54 +0530
commit1f60b8af97b15cb8e33f68c44f602cf69d79bd7a (patch)
treeb7ab11749fc4e20a9b4589ba2b97bd64991bb9f0 /tests/unit_node/crypto/crypto_key_test.ts
parent210f2911ce3f498524c0354e8f60d62e3dbc39ed (diff)
fix(ext/node): ECDH.publicKey() point encoding (#23013)
Diffstat (limited to 'tests/unit_node/crypto/crypto_key_test.ts')
-rw-r--r--tests/unit_node/crypto/crypto_key_test.ts13
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);
+ }
+});