Skip to content

Commit

Permalink
use n,k=64 for dsc, use new parsing library to build csca merkle tree
Browse files Browse the repository at this point in the history
  • Loading branch information
remicolin committed Dec 15, 2024
1 parent f86e709 commit ddd89e4
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1,551 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pragma circom 2.1.9;

include "../openpassport_dsc.circom";

component main { public [ merkle_root ] } = OPENPASSPORT_DSC(12, 64, 32, 120, 35, 1664, 256, 12);
component main { public [ merkle_root ] } = OPENPASSPORT_DSC(12, 64, 32, 64, 64, 1664, 256, 12);
24 changes: 12 additions & 12 deletions circuits/circuits/dsc/openpassport_dsc.circom
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma circom 2.1.9;

include "../utils/circomlib/bitify/bitify.circom";
include "../utils/circomlib/hasher/hash.circom";
include "../utils/circomlib/hasher/shaBytes/shaBytesDynamic.circom";
include "../utils/circomlib/bitify/comparators.circom";
include "../utils/circomlib/hasher/hash.circom";
include "../utils/circomlib/merkle-trees/binary-merkle-root.circom";
Expand Down Expand Up @@ -40,21 +40,21 @@ template OPENPASSPORT_DSC(signatureAlgorithm, n_dsc, k_dsc, n_csca, k_csca, max_
signal computed_merkle_root <== BinaryMerkleRoot(nLevels)(leaf, nLevels, path, siblings);
merkle_root === computed_merkle_root;

signal raw_dsc_cert_bits[max_cert_bytes * 8];
// signal raw_dsc_cert_bits[max_cert_bytes * 8];

component n2b[max_cert_bytes];
for (var i = 0; i < max_cert_bytes; i++) {
n2b[i] = Num2Bits(8);
n2b[i].in <== raw_dsc_cert[i];
for (var j = 0; j < 8; j++) {
raw_dsc_cert_bits[i * 8 + j] <== n2b[i].out[j];
}
}
// component n2b[max_cert_bytes];
// for (var i = 0; i < max_cert_bytes; i++) {
// n2b[i] = Num2Bits(8);
// n2b[i].in <== raw_dsc_cert[i];
// for (var j = 0; j < 8; j++) {
// raw_dsc_cert_bits[i * 8 + j] <== n2b[i].out[j];
// }
// }

// verify certificate signature
// signal hashedCertificate[hashLength] <== ShaBytesDynamic(hashLength, max_cert_bytes)(raw_dsc_cert, raw_dsc_cert_padded_bytes);
signal hashedCertificate[hashLength] <== ShaBytesDynamic(hashLength, max_cert_bytes)(raw_dsc_cert, raw_dsc_cert_padded_bytes);
// for now 512 but it can be 1024 as well
signal hashedCertificate[hashLength] <== ShaHashChunks((max_cert_bytes * 8) \ 512, hashLength)(raw_dsc_cert_bits, 0);
// signal hashedCertificate[hashLength] <== ShaHashChunks((max_cert_bytes * 8) \ 512, hashLength)(raw_dsc_cert_bits, 0);
SignatureVerifier(signatureAlgorithm, n_csca, k_csca)(hashedCertificate, csca_pubKey, signature);

// verify DSC csca_pubKey
Expand Down
4 changes: 2 additions & 2 deletions circuits/tests/dsc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { max_cert_bytes } from '../../common/src/constants/constants';
import { getCircuitName } from '../../common/src/utils/certificates/handleCertificate';

const sigAlgs = [
{ sigAlg: 'rsa', hashFunction: 'sha1', domainParameter: '65537', keyLength: '4096' },
// { sigAlg: 'rsa', hashFunction: 'sha1', domainParameter: '65537', keyLength: '4096' },
// { sigAlg: 'rsa', hashFunction: 'sha256', domainParameter: '65537', keyLength: '4096' },
// { sigAlg: 'rsapss', hashFunction: 'sha256', domainParameter: '65537', keyLength: '4096' },
{ sigAlg: 'rsapss', hashFunction: 'sha256', domainParameter: '65537', keyLength: '4096' },
];

sigAlgs.forEach(({ sigAlg, hashFunction, domainParameter, keyLength }) => {
Expand Down
Loading

0 comments on commit ddd89e4

Please sign in to comment.