Skip to content

Commit

Permalink
Merge pull request #45 from rarimo/refactor/register-identity
Browse files Browse the repository at this point in the history
Refactor/register identity
  • Loading branch information
1KitCat1 authored Oct 9, 2024
2 parents 31b9da1 + f8abb70 commit eddba80
Show file tree
Hide file tree
Showing 117 changed files with 1,842,253 additions and 1,125 deletions.
14 changes: 8 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ artifacts
cache
test/tests/inputs/*
temp_asn1.der
test/tests/__pycache__
!test/tests/*.py
!test/tests/inputs/credValidExceedsPassportInput.json
!test/tests/inputs/passportExpiredInput.json
!test/tests/inputs/isNotAdultInput.json
!test/tests/inputs/validInput.json
tests/tests/__pycache__
circuits/ecdsa/tmp/*
!tests/tests/*.py
!tests/tests/inputs/credValidExceedsPassportInput.json
!tests/tests/inputs/passportExpiredInput.json
!tests/tests/inputs/isNotAdultInput.json
!tests/tests/inputs/validInput.json
helpers/blacklist_generation/__pycache__
6 changes: 3 additions & 3 deletions circuits/bigInt/bigIntFunc.circom
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,11 @@ function prod_mod(CHUNK_SIZE, CHUNK_NUMBER, A, B, P) {
// A has CHUNK_NUMBER registers
// P has CHUNK_NUMBER registers
// EXP has CHUNK_NUMBER registers
// CHUNK_NUMBER * CHUNK_SIZE <= 500
// CHUNK_NUMBER * CHUNK_SIZE <= 513
// P is A prime
// computes A^EXP mod P
function mod_exp(CHUNK_SIZE, CHUNK_NUMBER, A, P, EXP) {
var eBits[500]; // length is CHUNK_NUMBER * CHUNK_SIZE
var eBits[513]; // length is CHUNK_NUMBER * CHUNK_SIZE
var BIT_LENGTH;
for (var i = 0; i < CHUNK_NUMBER; i++) {
for (var j = 0; j < CHUNK_SIZE; j++) {
Expand Down Expand Up @@ -477,7 +477,7 @@ function mod_exp(CHUNK_SIZE, CHUNK_NUMBER, A, P, EXP) {
// CHUNK_SIZE bits per register
// A has CHUNK_NUMBER registers
// P has CHUNK_NUMBER registers
// CHUNK_NUMBER * CHUNK_SIZE <= 500
// CHUNK_NUMBER * CHUNK_SIZE <= 513
// P is A prime
// if A == 0 mod P, returns 0
// else computes inv = A^(P-2) mod P
Expand Down
7 changes: 0 additions & 7 deletions circuits/ecdsa/BrainpoolSigVerify.circom

This file was deleted.

7 changes: 0 additions & 7 deletions circuits/ecdsa/P256SigVerify.circom

This file was deleted.

13 changes: 2 additions & 11 deletions circuits/ecdsa/brainpoolP256r1/brainpool.circom
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
pragma circom 2.1.8;
pragma circom 2.1.6;

include "./circomPairing/curve.circom";
include "./brainpoolFunc.circom";
include "./brainpoolPows.circom";
include "circomlib/circuits/multiplexer.circom";
include "circomlib/circuits/bitify.circom";
include "circomlib/circuits/comparators.circom";
include "../utils/func.circom";

template BrainpoolScalarMult(CHUNK_SIZE, CHUNK_NUMBER){
signal input scalar[CHUNK_NUMBER];
Expand Down Expand Up @@ -435,13 +436,3 @@ template BrainpoolPipingerMult(CHUNK_SIZE, CHUNK_NUMBER, WINDOW_SIZE){

out <== res[ADDERS_NUMBER];
}

function div_ceil(m, CHUNK_SIZE) {
var ret = 0;
if (m % CHUNK_SIZE == 0) {
ret = m \ CHUNK_SIZE;
} else {
ret = m \ CHUNK_SIZE + 1;
}
return ret;
}
2 changes: 1 addition & 1 deletion circuits/ecdsa/brainpoolP256r1/brainpoolFunc.circom
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma circom 2.1.8;
pragma circom 2.1.6;

function get_order(CHUNK_SIZE,CHUNK_NUMBER){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ template MillerLoop1(CHUNK_SIZE, CHUNK_NUMBER, b, r, q){
assert( 4*CHUNK_SIZE + LOGK3 < 251 );


var BITS[500]; // length is CHUNK_NUMBER * CHUNK_SIZE
var BITS[513]; // length is CHUNK_NUMBER * CHUNK_SIZE
var BIT_LENGTH;
var SIG_BITS=0;
for (var i = 0; i < CHUNK_NUMBER; i++) {
Expand Down Expand Up @@ -639,7 +639,7 @@ template MillerLoop2(CHUNK_SIZE, CHUNK_NUMBER, b, r, Q){
signal input Q[2][6][2][CHUNK_NUMBER];
signal output out[6][2][CHUNK_NUMBER];
var rBits[500]; // length is CHUNK_NUMBER * CHUNK_SIZE
var rBits[513]; // length is CHUNK_NUMBER * CHUNK_SIZE
var rBitLength;
var rSigBits=0;
for (var i = 0; i < CHUNK_NUMBER; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function get_fp_sgn0(a){
// CHUNK_SIZE bits per register
// num has CHUNK_NMBER registers
// p has CHUNK_NMBER registers
// CHUNK_NMBER * CHUNK_SIZE <= 500
// CHUNK_NMBER * CHUNK_SIZE <= 513
// p is a prime
// if num == 0 mod p, returns 0
// else computes inv = num^{-1} mod p using extended euclidean algorithm
Expand Down
4 changes: 2 additions & 2 deletions circuits/ecdsa/brainpoolP256r1/signatureVerification.circom
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma circom 2.1.8;
pragma circom 2.1.6;

include "./circomPairing/curve.circom";
include "circomlib/circuits/bitify.circom";
Expand Down Expand Up @@ -104,7 +104,7 @@ template verifyBrainpool(CHUNK_SIZE,CHUNK_NUMBER, ALGO){
signal tmpPoint2[2][6];

component scalarMult1 = BrainpoolGeneratorMultiplication(43,6);
component scalarMult2 = BrainpoolScalarMult(43,6);
component scalarMult2 = BrainpoolPipingerMult(43,6,4);

scalarMult1.scalar <== sh;

Expand Down
Loading

0 comments on commit eddba80

Please sign in to comment.