From 20a11f6106c15366d95b59e525136b54516b6b09 Mon Sep 17 00:00:00 2001 From: 0xvikasrushi <0xvikas@gmail.com> Date: Sun, 1 Sep 2024 19:18:28 +0530 Subject: [PATCH] fix: ecdsa res --- tests/ecdsa.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/ecdsa.test.ts b/tests/ecdsa.test.ts index b65023d..de3a23b 100644 --- a/tests/ecdsa.test.ts +++ b/tests/ecdsa.test.ts @@ -23,7 +23,7 @@ describe.only("ECDSA", () => { const keyPair = p384.genKeyPair(); const msgHash = crypto.createHash("sha384").update("hello world").digest("hex"); - const msgHash1 = crypto.createHash("sha384").update("kajsd asdnasjkldn asjkdnas ").digest("hex"); + const wrongMessageHash = crypto.createHash("sha384").update("Sui Sui").digest("hex"); const signature = keyPair.sign(msgHash); const decodedRes = decode(Uint8Array.from(signature.toDER())); @@ -35,9 +35,14 @@ describe.only("ECDSA", () => { const pubkey_y = splitToWords(hexToBigInt(pubkey.subarray(49, 49 + 48).toString("hex")), 48n, 8n); circuit.expectPass( - { r, s, msghash: splitToWords(hexToBigInt(msgHash1), 48n, 8n), pubkey: [pubkey_x, pubkey_y] }, + { r, s, msghash: splitToWords(hexToBigInt(wrongMessageHash), 48n, 8n), pubkey: [pubkey_x, pubkey_y] }, { result: "0" } ); + + circuit.expectPass( + { r, s, msghash: splitToWords(hexToBigInt(msgHash), 48n, 8n), pubkey: [pubkey_x, pubkey_y] }, + { result: "1" } + ); }); }); });