From da829354bfbdfb09dae73686f466da71bedb573e Mon Sep 17 00:00:00 2001 From: 0xturboblitz Date: Sat, 3 Aug 2024 13:38:00 -0700 Subject: [PATCH] fix few details and typos --- .../register_ecdsaWithSHA1Encryption.circom | 1 + .../register_ecdsaWithSHA256Encryption.circom | 1 + ...egister_sha1WithRSAEncryption_65537.circom | 2 +- .../register_sha256WithRSASSAPSS_65537.circom | 2 +- ...ster_sha256WithRSASSAPSS_65537.circom.save | 61 ------------------- .../tests/register/register_sha1_rsa.test.ts | 2 +- common/src/constants/mockPassportData.ts | 5 +- 7 files changed, 8 insertions(+), 66 deletions(-) delete mode 100644 circuits/circuits/register/register_sha256WithRSASSAPSS_65537.circom.save diff --git a/circuits/circuits/register/register_ecdsaWithSHA1Encryption.circom b/circuits/circuits/register/register_ecdsaWithSHA1Encryption.circom index 2def27845..3e38033b9 100644 --- a/circuits/circuits/register/register_ecdsaWithSHA1Encryption.circom +++ b/circuits/circuits/register/register_ecdsaWithSHA1Encryption.circom @@ -83,4 +83,5 @@ template Register_ecdsaWithSHA1Encryption(n, k, max_datahashes_bytes, nLevels, s signal output commitment <== poseidon_hasher.out; } +// We hardcode 7 here for ecdsa_with_SHA1 component main { public [ attestation_id ] } = Register_ecdsaWithSHA1Encryption(43, 6, 320, 16, 7); diff --git a/circuits/circuits/register/register_ecdsaWithSHA256Encryption.circom b/circuits/circuits/register/register_ecdsaWithSHA256Encryption.circom index 3d7241185..3b5184557 100644 --- a/circuits/circuits/register/register_ecdsaWithSHA256Encryption.circom +++ b/circuits/circuits/register/register_ecdsaWithSHA256Encryption.circom @@ -83,4 +83,5 @@ template Register_ecdsaWithSHA256Encryption(n, k, max_datahashes_bytes, nLevels, signal output commitment <== poseidon_hasher.out; } +// We hardcode 8 here for ecdsa_with_SHA256 component main { public [ attestation_id ] } = Register_ecdsaWithSHA256Encryption(43, 6, 320, 16, 8); diff --git a/circuits/circuits/register/register_sha1WithRSAEncryption_65537.circom b/circuits/circuits/register/register_sha1WithRSAEncryption_65537.circom index 19d7859a8..ee72634c6 100644 --- a/circuits/circuits/register/register_sha1WithRSAEncryption_65537.circom +++ b/circuits/circuits/register/register_sha1WithRSAEncryption_65537.circom @@ -62,5 +62,5 @@ template Register_sha1WithRSAEncryption_65537(n, k, max_datahashes_bytes, nLevel } -// We hardcode 1 here for sha1WithRSAEncryption_65537 +// We hardcode 3 here for sha1WithRSAEncryption_65537 component main { public [ attestation_id ] } = Register_sha1WithRSAEncryption_65537(121, 17, 320, 16, 3); diff --git a/circuits/circuits/register/register_sha256WithRSASSAPSS_65537.circom b/circuits/circuits/register/register_sha256WithRSASSAPSS_65537.circom index 6d93ad5ef..fc6a096a9 100644 --- a/circuits/circuits/register/register_sha256WithRSASSAPSS_65537.circom +++ b/circuits/circuits/register/register_sha256WithRSASSAPSS_65537.circom @@ -62,5 +62,5 @@ template register_sha256WithRSASSAPSS_65537(n, k, max_datahashes_bytes, nLevels, } -// We hardcode 1 here for sha256WithRSAEncryption_65537 +// We hardcode 4 here for sha256WithRSASSAPSS_65537 component main { public [ attestation_id ] } = register_sha256WithRSASSAPSS_65537(64, 32, 320, 16, 4); diff --git a/circuits/circuits/register/register_sha256WithRSASSAPSS_65537.circom.save b/circuits/circuits/register/register_sha256WithRSASSAPSS_65537.circom.save deleted file mode 100644 index f04560d43..000000000 --- a/circuits/circuits/register/register_sha256WithRSASSAPSS_65537.circom.save +++ /dev/null @@ -1,61 +0,0 @@ -pragma circom 2.1.5; - -include "circomlib/circuits/poseidon.circom"; -include "@zk-email/circuits/utils/bytes.circom"; -include "./verifier/passport_verifier_sha256WithRSASSAPSS_65537.circom"; -include "../utils/chunk_data.circom"; -include "../utils/compute_pubkey_leaf.circom"; -include "binary-merkle-root.circom"; - -template register_sha256WithRSASSAPSS_65537(n, k, max_datahashes_bytes, nLevels, signatureAlgorithm) { - signal input secret; - - signal input mrz[93]; - signal input dg1_hash_offset; - signal input econtent[max_datahashes_bytes]; - signal input datahashes_padded_length; - signal input signed_attributes[104]; - signal input signature[k]; - - signal input pubkey[k]; - signal input merkle_root; - signal input path[nLevels]; - signal input siblings[nLevels]; - - signal input attestation_id; - - // Verify inclusion of the pubkey in the pubkey tree - signal leaf <== ComputePubkeyLeaf(n, k, signatureAlgorithm)(pubkey); - signal computed_merkle_root <== BinaryMerkleRoot(nLevels)(leaf, nLevels, path, siblings); - merkle_root === computed_merkle_root; - - // Verify passport validity - component PV = PassportVerifier_sha256WithRSASSAPSS_65537(n, k, max_datahashes_bytes); - PV.mrz <== mrz; - PV.dg1_hash_offset <== dg1_hash_offset; - PV.dataHashes <== econtent; - PV.datahashes_padded_length <== datahashes_padded_length; - PV.eContentBytes <== signed_attributes; - PV.pubkey <== pubkey; - PV.signature <== signature; - - // Generate the commitment - component poseidon_hasher = Poseidon(6); - poseidon_hasher.inputs[0] <== secret; - poseidon_hasher.inputs[1] <== attestation_id; - poseidon_hasher.inputs[2] <== leaf; - - signal mrz_packed[3] <== PackBytes(93)(mrz); - for (var i = 0; i < 3; i++) { - poseidon_hasher.inputs[i + 3] <== mrz_packed[i]; - } - signal output commitment <== poseidon_hasher.out; - - // Generate the nullifier - var chunk_size = 11; // Since ceil(32 / 3) in integer division is 11 - signal chunked_signature[chunk_size] <== ChunkData(n, k, chunk_size)(signature); - signal output nullifier <== Poseidon(chunk_size)(chunked_signature); -} - -// We hardcode 1 here for sha256WithRSAEncryption_65537 -component main { public [ merkle_root, attestation_id ] } = register_sha256WithRSASSAPSS_65537(121, 17, 320, 16, 4); diff --git a/circuits/tests/register/register_sha1_rsa.test.ts b/circuits/tests/register/register_sha1_rsa.test.ts index 68cc733d3..fc9de7058 100644 --- a/circuits/tests/register/register_sha1_rsa.test.ts +++ b/circuits/tests/register/register_sha1_rsa.test.ts @@ -27,7 +27,7 @@ describe('Register - SHA1 RSA', function () { './node_modules/@zk-kit/binary-merkle-root.circom/src', './node_modules/circomlib/circuits', './node_modules/dmpierre/sha1-circom/circuits', - './node_modules/@zk-email/circuits ', + './node_modules/@zk-email/circuits', ], } ); diff --git a/common/src/constants/mockPassportData.ts b/common/src/constants/mockPassportData.ts index e229b8871..c184f9089 100644 --- a/common/src/constants/mockPassportData.ts +++ b/common/src/constants/mockPassportData.ts @@ -47,6 +47,7 @@ export const mockPassportData_sha256_rsa_65537 = { ], photoBase64: 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABjElEQVR42mL8//8/AyUYiBQYmIw3...', }; + export const mockPassportData_sha1_rsa_65537 = { mrz: 'P