Skip to content

Commit

Permalink
fix: ecdsa res
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVikasRushi committed Sep 1, 2024
1 parent 94c2d0f commit 20a11f6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/ecdsa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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" }
);
});
});
});

0 comments on commit 20a11f6

Please sign in to comment.