Skip to content

Commit

Permalink
Merge pull request #317 from zk-passport/tests/ecdsa
Browse files Browse the repository at this point in the history
add tests for rest of the curves
  • Loading branch information
remicolin authored Jan 21, 2025
2 parents 6fc2e39 + 1d3252a commit ded4596
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
13 changes: 13 additions & 0 deletions circuits/circuits/tests/utils/ecdsa/test_brainpoolP512r1.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma circom 2.1.9;

include "../../../utils/crypto/signature/ecdsa/ecdsaVerifier.circom";

template VerifyBrainpoolP384r1Sha384() {
signal input signature[2 * 8];
signal input pubKey[2 * 8];
signal input hashParsed[512];

EcdsaVerifier(29, 64, 8)(signature, pubKey, hashParsed);
}

component main = VerifyBrainpoolP384r1Sha384();
13 changes: 13 additions & 0 deletions circuits/circuits/tests/utils/ecdsa/test_p256.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma circom 2.1.9;

include "../../../utils/crypto/signature/ecdsa/ecdsaVerifier.circom";

template VerifyP256Sha256() {
signal input signature[2 * 4];
signal input pubKey[2 * 4];
signal input hashParsed[256];

EcdsaVerifier(8, 64, 4)(signature, pubKey, hashParsed);
}

component main = VerifyP256Sha256();
13 changes: 13 additions & 0 deletions circuits/circuits/tests/utils/ecdsa/test_p384.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma circom 2.1.9;

include "../../../utils/crypto/signature/ecdsa/ecdsaVerifier.circom";

template VerifyP384r1Sha384() {
signal input signature[2 * 6];
signal input pubKey[2 * 6];
signal input hashParsed[384];

EcdsaVerifier(9, 64, 6)(signature, pubKey, hashParsed);
}

component main = VerifyP384r1Sha384();
21 changes: 21 additions & 0 deletions circuits/tests/utils/ecdsa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ const testSuite = [
k: 6,
reason: 'when hash bits are the same as curve bits',
},
{
hash: 'sha512',
curve: 'brainpoolP512r1',
n: 64,
k: 8,
reason: 'when hash bits are the same as curve bits',
},
{
hash: 'sha256',
curve: 'p256',
n: 64,
k: 4,
reason: 'when hash bits are the same as curve bits',
},
{
hash: 'sha384',
curve: 'p384',
n: 64,
k: 6,
reason: 'when hash bits are the same as curve bits',
},
];

describe('ecdsa', () => {
Expand Down

0 comments on commit ded4596

Please sign in to comment.