mirror of
https://github.com/selfxyz/self.git
synced 2026-04-27 03:01:15 -04:00
update prove circuits
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
pragma circom 2.1.5;
|
||||
|
||||
include "circomlib/circuits/poseidon.circom";
|
||||
include "@zk-email/circuits/utils/bytes.circom";
|
||||
include "../utils/isOlderThan.circom";
|
||||
include "../utils/isValid.circom";
|
||||
include "../utils/other/bytes.circom";
|
||||
include "../utils/passport/date/isOlderThan.circom";
|
||||
include "../utils/passport/date/isValid.circom";
|
||||
include "binary-merkle-root.circom";
|
||||
include "../utils/isValid.circom";
|
||||
|
||||
template DISCLOSE() {
|
||||
signal input mrz[93];
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../openpassport_prove.circom";
|
||||
|
||||
component main = OPENPASSPORT_PROVE(7, 43, 6, 448, 448);
|
||||
@@ -0,0 +1,5 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../openpassport_prove.circom";
|
||||
|
||||
component main = OPENPASSPORT_PROVE(8, 43, 6, 640, 512);
|
||||
@@ -0,0 +1,5 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../openpassport_prove.circom";
|
||||
|
||||
component main = OPENPASSPORT_PROVE(3, 64, 32, 448, 448);
|
||||
@@ -0,0 +1,5 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../openpassport_prove.circom";
|
||||
|
||||
component main = OPENPASSPORT_PROVE(1, 64, 32, 640, 512);
|
||||
@@ -0,0 +1,5 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../openpassport_prove.circom";
|
||||
|
||||
component main = OPENPASSPORT_PROVE(4, 64, 32, 640, 512);
|
||||
42
circuits/circuits/prove/openpassport_prove.circom
Normal file
42
circuits/circuits/prove/openpassport_prove.circom
Normal file
@@ -0,0 +1,42 @@
|
||||
pragma circom 2.1.6;
|
||||
|
||||
include "../utils/passport/customHashers.circom";
|
||||
include "../utils/passport/computeCommitment.circom";
|
||||
include "../utils/passport/signatureAlgorithm.circom";
|
||||
include "../utils/passport/passportVerifier.circom";
|
||||
include "../disclose/disclose.circom";
|
||||
template OPENPASSPORT_PROVE(signatureAlgorithm, n, k, MAX_ECONTENT_PADDED_LEN, MAX_SIGNED_ATTR_PADDED_LEN) {
|
||||
var kLengthFactor = getKLengthFactor(signatureAlgorithm);
|
||||
var kScaled = k * kLengthFactor;
|
||||
|
||||
signal input dg1[93];
|
||||
signal input dg1_hash_offset;
|
||||
signal input econtent[MAX_ECONTENT_PADDED_LEN];
|
||||
signal input econtent_padded_length;
|
||||
signal input signed_attr[MAX_SIGNED_ATTR_PADDED_LEN];
|
||||
signal input signed_attr_padded_length;
|
||||
signal input signed_attr_econtent_hash_offset;
|
||||
signal input signature[kScaled];
|
||||
signal input pubKey[kScaled];
|
||||
|
||||
// passport verifier
|
||||
PassportVerifier(signatureAlgorithm, n, k, MAX_ECONTENT_PADDED_LEN, MAX_SIGNED_ATTR_PADDED_LEN)(dg1,dg1_hash_offset,econtent,econtent_padded_length, signed_attr, signed_attr_padded_length, signed_attr_econtent_hash_offset, pubKey, signature);
|
||||
|
||||
// nullifier
|
||||
signal output nullifier <== CustomHasher(kScaled)(signature);
|
||||
|
||||
signal input scope;
|
||||
signal input bitmap[90];
|
||||
signal input current_date[6]; // YYMMDD - num
|
||||
signal input majority[2]; // YY - ASCII
|
||||
signal input user_identifier;
|
||||
|
||||
component disclose = DISCLOSE();
|
||||
disclose.mrz <== dg1;
|
||||
disclose.bitmap <== bitmap;
|
||||
disclose.current_date <== current_date;
|
||||
disclose.majority <== majority;
|
||||
|
||||
signal output revealedData_packed[3] <== disclose.revealedData_packed;
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
pragma circom 2.1.5;
|
||||
|
||||
include "circomlib/circuits/poseidon.circom";
|
||||
include "@zk-email/circuits/utils/bytes.circom";
|
||||
include "../verifier/passport_verifier_rsa_65537_sha1.circom";
|
||||
include "binary-merkle-root.circom";
|
||||
include "../utils/splitSignalsToWords.circom";
|
||||
include "../disclose/disclose.circom";
|
||||
|
||||
template PROVE_RSA_65537_SHA1(n, k, max_datahashes_bytes) {
|
||||
/*** CUSTOM IMPLEMENTATION ***/
|
||||
signal input mrz[93];
|
||||
signal input dg1_hash_offset;
|
||||
signal input dataHashes[max_datahashes_bytes];
|
||||
signal input datahashes_padded_length;
|
||||
signal input eContent[92];
|
||||
signal input signature[k];
|
||||
signal input dsc_modulus[k];
|
||||
signal output signature_algorithm <== 000;
|
||||
|
||||
// Verify passport validity
|
||||
component PV = PASSPORT_VERIFIER_RSA_65537_SHA1(n, k, max_datahashes_bytes);
|
||||
PV.mrz <== mrz;
|
||||
PV.dg1_hash_offset <== dg1_hash_offset;
|
||||
PV.dataHashes <== dataHashes;
|
||||
PV.datahashes_padded_length <== datahashes_padded_length;
|
||||
PV.eContentBytes <== eContent;
|
||||
PV.dsc_modulus <== dsc_modulus;
|
||||
PV.signature <== signature;
|
||||
|
||||
/*** COMMON TO ALL CIRCUITS ***/
|
||||
signal input scope;
|
||||
signal input bitmap[90];
|
||||
signal input current_date[6]; // YYMMDD - num
|
||||
signal input majority[2]; // YY - ASCII
|
||||
signal input user_identifier;
|
||||
|
||||
// verify passport validity and disclose optional data
|
||||
component disclose = DISCLOSE();
|
||||
disclose.mrz <== mrz;
|
||||
disclose.bitmap <== bitmap;
|
||||
disclose.current_date <== current_date;
|
||||
disclose.majority <== majority;
|
||||
signal output revealedData_packed[3] <== disclose.revealedData_packed;
|
||||
|
||||
// generate nullifier
|
||||
signal split_signature[9] <== SplitSignalsToWords(n, k, 230, 9)(signature);
|
||||
component nullifier_hasher = Poseidon(10);
|
||||
for (var i = 0; i < 9; i++) {
|
||||
nullifier_hasher.inputs[i] <== split_signature[i];
|
||||
}
|
||||
nullifier_hasher.inputs[9] <== scope;
|
||||
signal output nullifier <== nullifier_hasher.out;
|
||||
}
|
||||
|
||||
component main { public [ dsc_modulus, scope, user_identifier, current_date ] } = PROVE_RSA_65537_SHA1(64, 32, 320);
|
||||
@@ -1,56 +0,0 @@
|
||||
pragma circom 2.1.5;
|
||||
|
||||
include "circomlib/circuits/poseidon.circom";
|
||||
include "@zk-email/circuits/utils/bytes.circom";
|
||||
include "../verifier/passport_verifier_rsa_65537_sha256.circom";
|
||||
include "binary-merkle-root.circom";
|
||||
include "../utils/splitSignalsToWords.circom";
|
||||
include "../disclose/disclose.circom";
|
||||
|
||||
template PROVE_RSA_65537_SHA256(n, k, max_datahashes_bytes) {
|
||||
/*** CUSTOM IMPLEMENTATION ***/
|
||||
signal input mrz[93];
|
||||
signal input dg1_hash_offset;
|
||||
signal input dataHashes[max_datahashes_bytes];
|
||||
signal input datahashes_padded_length;
|
||||
signal input eContent[104];
|
||||
signal input signature[k];
|
||||
signal input dsc_modulus[k];
|
||||
signal output signature_algorithm <== 001;
|
||||
|
||||
// Verify passport validity
|
||||
component PV = PASSPORT_VERIFIER_RSA_65537_SHA256(n, k, max_datahashes_bytes);
|
||||
PV.mrz <== mrz;
|
||||
PV.dg1_hash_offset <== dg1_hash_offset;
|
||||
PV.dataHashes <== dataHashes;
|
||||
PV.datahashes_padded_length <== datahashes_padded_length;
|
||||
PV.eContentBytes <== eContent;
|
||||
PV.dsc_modulus <== dsc_modulus;
|
||||
PV.signature <== signature;
|
||||
|
||||
/*** COMMON TO ALL CIRCUITS ***/
|
||||
signal input scope;
|
||||
signal input bitmap[90];
|
||||
signal input current_date[6]; // YYMMDD - num
|
||||
signal input majority[2]; // YY - ASCII
|
||||
signal input user_identifier;
|
||||
|
||||
// verify passport validity and disclose optional data
|
||||
component disclose = DISCLOSE();
|
||||
disclose.mrz <== mrz;
|
||||
disclose.bitmap <== bitmap;
|
||||
disclose.current_date <== current_date;
|
||||
disclose.majority <== majority;
|
||||
signal output revealedData_packed[3] <== disclose.revealedData_packed;
|
||||
|
||||
// generate nullifier
|
||||
signal split_signature[9] <== SplitSignalsToWords(n, k, 230, 9)(signature);
|
||||
component nullifier_hasher = Poseidon(10);
|
||||
for (var i = 0; i < 9; i++) {
|
||||
nullifier_hasher.inputs[i] <== split_signature[i];
|
||||
}
|
||||
nullifier_hasher.inputs[9] <== scope;
|
||||
signal output nullifier <== nullifier_hasher.out;
|
||||
}
|
||||
|
||||
component main { public [ dsc_modulus, scope, user_identifier, current_date ] } = PROVE_RSA_65537_SHA256(64, 32, 320);
|
||||
@@ -1,56 +0,0 @@
|
||||
pragma circom 2.1.5;
|
||||
|
||||
include "circomlib/circuits/poseidon.circom";
|
||||
include "@zk-email/circuits/utils/bytes.circom";
|
||||
include "../verifier/passport_verifier_rsapss_65537_sha256.circom";
|
||||
include "binary-merkle-root.circom";
|
||||
include "../utils/splitSignalsToWords.circom";
|
||||
include "../disclose/disclose.circom";
|
||||
|
||||
template PROVE_RSAPSS_65537_SHA256(n, k, max_datahashes_bytes) {
|
||||
/*** CUSTOM IMPLEMENTATION ***/
|
||||
signal input mrz[93];
|
||||
signal input dg1_hash_offset;
|
||||
signal input dataHashes[max_datahashes_bytes];
|
||||
signal input datahashes_padded_length;
|
||||
signal input eContent[104];
|
||||
signal input signature[k];
|
||||
signal input dsc_modulus[k];
|
||||
signal output signature_algorithm <== 001;
|
||||
|
||||
// Verify passport validity
|
||||
component PV = PASSPORT_VERIFIER_RSAPSS_65537_SHA256(n, k, max_datahashes_bytes);
|
||||
PV.mrz <== mrz;
|
||||
PV.dg1_hash_offset <== dg1_hash_offset;
|
||||
PV.dataHashes <== dataHashes;
|
||||
PV.datahashes_padded_length <== datahashes_padded_length;
|
||||
PV.eContentBytes <== eContent;
|
||||
PV.dsc_modulus <== dsc_modulus;
|
||||
PV.signature <== signature;
|
||||
|
||||
/*** COMMON TO ALL CIRCUITS ***/
|
||||
signal input scope;
|
||||
signal input bitmap[90];
|
||||
signal input current_date[6]; // YYMMDD - num
|
||||
signal input majority[2]; // YY - ASCII
|
||||
signal input user_identifier;
|
||||
|
||||
// verify passport validity and disclose optional data
|
||||
component disclose = DISCLOSE();
|
||||
disclose.mrz <== mrz;
|
||||
disclose.bitmap <== bitmap;
|
||||
disclose.current_date <== current_date;
|
||||
disclose.majority <== majority;
|
||||
signal output revealedData_packed[3] <== disclose.revealedData_packed;
|
||||
|
||||
// generate nullifier
|
||||
signal split_signature[9] <== SplitSignalsToWords(n, k, 230, 9)(signature);
|
||||
component nullifier_hasher = Poseidon(10);
|
||||
for (var i = 0; i < 9; i++) {
|
||||
nullifier_hasher.inputs[i] <== split_signature[i];
|
||||
}
|
||||
nullifier_hasher.inputs[9] <== scope;
|
||||
signal output nullifier <== nullifier_hasher.out;
|
||||
}
|
||||
|
||||
component main { public [ dsc_modulus, scope, user_identifier, current_date ] } = PROVE_RSAPSS_65537_SHA256(64, 32, 320);
|
||||
Reference in New Issue
Block a user