Skip to content

Commit 58e2a40

Browse files
authored
Merge pull request #48 from erdoganishe/dev
Add Zkit tests with mock (waiting new zkit version)
2 parents 15c7217 + a19ea63 commit 58e2a40

File tree

50 files changed

+2422
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2422
-286
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ circuits/ecdsa/tmp/*
3737
!tests/tests/inputs/validInput.json
3838
helpers/blacklist_generation/__pycache__
3939
package-lock.json
40+
test/passports/*
41+
test/inputs/*
42+
test/registerIdentityTest.ts
43+
test/circuits/*
44+
!test/passports/readme.txt

.mocharc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"require": "hardhat/register",
3-
"timeout": 100000,
4-
"_": ["test/**/*.ts"]
3+
"timeout": 10000000,
4+
"_": ["test/**/*.ts"],
5+
"ignore": "test/generateRegisterIdentityTest.js"
56
}

circuits/dateUtilities/dateComparison.circom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma circom 2.1.6;
22

3-
include "../node_modules/circomlib/circuits/comparators.circom";
3+
include "circomlib/circuits/comparators.circom";
44

55
template DateIsLess() {
66
signal input firstDay;

circuits/dateUtilities/dateDecoder.circom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma circom 2.1.6;
22

3-
include "../node_modules/circomlib/circuits/bitify.circom";
3+
include "circomlib/circuits/bitify.circom";
44
include "./dateEncoder.circom";
55

66
template DateDecoder() {

circuits/ecdsa/brainpoolP256r1/circomPairing/bls12_381Func.circom

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@ function get_BLS12_381_prime(CHUNK_SIZE, CHUNK_NUMBER){
2222

2323
// half of 8th ROOTS of unity, up to negation
2424
function get_roots_of_unity(CHUNK_SIZE, CHUNK_NUMBER){
25-
assert( CHUNK_SIZE == 55 && CHUNK_NUMBER == 7 );
25+
26+
assert(CHUNK_SIZE == 55 && CHUNK_NUMBER == 7);
27+
2628
var ROOTS[4][2][150];
29+
2730
for(var idx=0; idx<CHUNK_NUMBER; idx++){
2831
ROOTS[0][0][idx] = 0;
2932
ROOTS[0][1][idx] = 0;
3033
ROOTS[1][0][idx] = 0;
3134
ROOTS[1][1][idx] = 0;
3235
}
36+
3337
ROOTS[0][0][0] = 1; // ROOTS[0] = 1
3438
ROOTS[1][1][0] = 1; // ROOTS[1] = sqrt(-1)
3539

36-
if( CHUNK_SIZE == 55 && CHUNK_NUMBER == 7 ){
40+
if(CHUNK_SIZE == 55 && CHUNK_NUMBER == 7){
3741
ROOTS[2][0] = [4649817190157321,
3842
14178090100713872,
3943
25898210532243870,
@@ -67,11 +71,11 @@ function get_roots_of_unity(CHUNK_SIZE, CHUNK_NUMBER){
6771
}
6872

6973
function get_etas(CHUNK_SIZE, CHUNK_NUMBER){
70-
assert( CHUNK_SIZE == 55 && CHUNK_NUMBER == 7 );
74+
assert(CHUNK_SIZE == 55 && CHUNK_NUMBER == 7);
7175
var p[150] = get_BLS12_381_prime(CHUNK_SIZE, CHUNK_NUMBER);
7276
var ETAS[4][2][150];
7377

74-
if( CHUNK_SIZE == 55 && CHUNK_NUMBER == 7 ){
78+
if(CHUNK_SIZE == 55 && CHUNK_NUMBER == 7){
7579
ETAS[0][0] = [15111404105178256,
7680
12179658998385743,
7781
23072200951145993,
@@ -111,8 +115,11 @@ function get_etas(CHUNK_SIZE, CHUNK_NUMBER){
111115
// coefficients for the 3-isogeny map from E2' to E2
112116
// taken from E.3 of https://cfrg.github.io/draft-irtf-cfrg-hash-to-curve/draft-irtf-cfrg-hash-to-curve.html#appendix-E.3
113117
function get_iso3_coeffs(CHUNK_SIZE, CHUNK_NUMBER){
118+
114119
assert( CHUNK_SIZE == 55 && CHUNK_NUMBER == 7 );
120+
115121
var COEFFS[4][4][2][150];
122+
116123
if( CHUNK_SIZE == 55 && CHUNK_NUMBER == 7 ){
117124
COEFFS[0][0][0] = [15950248680265686, 32024958503631044, 4244301805875352, 29783714120969249, 35703698803053471, 29228779030399226, 406640325010316];
118125
COEFFS[0][0][1] = [15950248680265686, 32024958503631044, 4244301805875352, 29783714120969249, 35703698803053471, 29228779030399226, 406640325010316];
@@ -151,7 +158,9 @@ function get_iso3_coeffs(CHUNK_SIZE, CHUNK_NUMBER){
151158
}
152159

153160
function get_generator_G1(CHUNK_SIZE, CHUNK_NUMBER){
154-
assert( CHUNK_SIZE == 55 && CHUNK_NUMBER == 7 );
161+
162+
assert(CHUNK_SIZE == 55 && CHUNK_NUMBER == 7);
163+
155164
var G1[2][150];
156165

157166
G1[0] = [16589478066046651,
@@ -173,7 +182,9 @@ function get_generator_G1(CHUNK_SIZE, CHUNK_NUMBER){
173182
}
174183

175184
function get_generator_G2(CHUNK_SIZE, CHUNK_NUMBER){
176-
assert( CHUNK_SIZE == 55 && CHUNK_NUMBER == 7 );
185+
186+
assert(CHUNK_SIZE == 55 && CHUNK_NUMBER == 7);
187+
177188
var G2[2][2][150];
178189

179190
G2[0][0] = [95420233661880, 1773856045391785, 5044075188989616, 23082975677810779, 22805092780977487, 23121359448368568, 161253150172098];
@@ -185,12 +196,15 @@ function get_generator_G2(CHUNK_SIZE, CHUNK_NUMBER){
185196
}
186197

187198
function get_Fp12_frobenius(CHUNK_SIZE, CHUNK_NUMBER){
199+
188200
assert( (CHUNK_SIZE==96 && CHUNK_NUMBER==4) || (CHUNK_SIZE==77 && CHUNK_NUMBER==5) || (CHUNK_SIZE==55 && CHUNK_NUMBER==7) );
189-
var COEFF[12][6][2][20]; //
201+
202+
var COEFF[12][6][2][20];
203+
190204
// COEFF[j][i] represents an element in F_q^2
191205
// F_q^12 = F_q^2[w] / (w^6 - (u+1))
192206
// Apply Frobenius j times to w^i: (w^i)^(q^j) = COEFF[j][i] * w^i
193-
if( CHUNK_SIZE==96 && CHUNK_NUMBER==4 ){
207+
if( CHUNK_SIZE == 96 && CHUNK_NUMBER == 4){
194208
COEFF[0][0][0][0] = 1;
195209
COEFF[0][0][0][1] = 0;
196210
COEFF[0][0][0][2] = 0;
@@ -2929,5 +2943,6 @@ function get_Fp12_frobenius(CHUNK_SIZE, CHUNK_NUMBER){
29292943
COEFF[11][5][1][5] = 1778035881690211;
29302944
COEFF[11][5][1][6] = 69335985795384;
29312945
}
2946+
29322947
return COEFF;
29332948
}

0 commit comments

Comments
 (0)