@@ -6,7 +6,7 @@ import calculateNullifierHash from "./calculateNullifierHash"
6
6
import generateProof from "./generateProof"
7
7
import hash from "./hash"
8
8
import packProof from "./packProof"
9
- import { FullProof } from "./types"
9
+ import { SemaphoreProof } from "./types"
10
10
import unpackProof from "./unpackProof"
11
11
import verifyProof from "./verifyProof"
12
12
@@ -21,7 +21,7 @@ describe("Proof", () => {
21
21
22
22
const identity = new Identity ( )
23
23
24
- let fullProof : FullProof
24
+ let fullProof : SemaphoreProof
25
25
let curve : any
26
26
27
27
beforeAll ( async ( ) => {
@@ -34,9 +34,7 @@ describe("Proof", () => {
34
34
35
35
describe ( "# generateProof" , ( ) => {
36
36
it ( "Should not generate Semaphore proofs if the identity is not part of the group" , async ( ) => {
37
- const group = new Group ( treeDepth )
38
-
39
- group . addMembers ( [ BigInt ( 1 ) , BigInt ( 2 ) ] )
37
+ const group = new Group ( treeDepth , 20 , [ BigInt ( 1 ) , BigInt ( 2 ) ] )
40
38
41
39
const fun = ( ) =>
42
40
generateProof ( identity , group , externalNullifier , signal , {
@@ -48,19 +46,15 @@ describe("Proof", () => {
48
46
} )
49
47
50
48
it ( "Should not generate a Semaphore proof with default snark artifacts with Node.js" , async ( ) => {
51
- const group = new Group ( treeDepth )
52
-
53
- group . addMembers ( [ BigInt ( 1 ) , BigInt ( 2 ) , identity . commitment ] )
49
+ const group = new Group ( treeDepth , 20 , [ BigInt ( 1 ) , BigInt ( 2 ) , identity . commitment ] )
54
50
55
51
const fun = ( ) => generateProof ( identity , group , externalNullifier , signal )
56
52
57
53
await expect ( fun ) . rejects . toThrow ( "ENOENT: no such file or directory" )
58
54
} )
59
55
60
56
it ( "Should generate a Semaphore proof passing a group as parameter" , async ( ) => {
61
- const group = new Group ( treeDepth )
62
-
63
- group . addMembers ( [ BigInt ( 1 ) , BigInt ( 2 ) , identity . commitment ] )
57
+ const group = new Group ( treeDepth , 20 , [ BigInt ( 1 ) , BigInt ( 2 ) , identity . commitment ] )
64
58
65
59
fullProof = await generateProof ( identity , group , externalNullifier , signal , {
66
60
wasmFilePath,
@@ -72,9 +66,7 @@ describe("Proof", () => {
72
66
} , 20000 )
73
67
74
68
it ( "Should generate a Semaphore proof passing a Merkle proof as parameter" , async ( ) => {
75
- const group = new Group ( treeDepth )
76
-
77
- group . addMembers ( [ BigInt ( 1 ) , BigInt ( 2 ) , identity . commitment ] )
69
+ const group = new Group ( treeDepth , 20 , [ BigInt ( 1 ) , BigInt ( 2 ) , identity . commitment ] )
78
70
79
71
fullProof = await generateProof ( identity , group . generateMerkleProof ( 2 ) , externalNullifier , signal , {
80
72
wasmFilePath,
@@ -104,47 +96,35 @@ describe("Proof", () => {
104
96
it ( "Should hash the signal value correctly" , async ( ) => {
105
97
const signalHash = hash ( signal )
106
98
107
- expect ( signalHash . toString ( ) ) . toBe (
108
- "8665846418922331996225934941481656421248110469944536651334918563951783029"
109
- )
99
+ expect ( signalHash ) . toBe ( "8665846418922331996225934941481656421248110469944536651334918563951783029" )
110
100
} )
111
101
112
102
it ( "Should hash the external nullifier value correctly" , async ( ) => {
113
103
const externalNullifierHash = hash ( externalNullifier )
114
104
115
- expect ( externalNullifierHash . toString ( ) ) . toBe (
105
+ expect ( externalNullifierHash ) . toBe (
116
106
"244178201824278269437519042830883072613014992408751798420801126401127326826"
117
107
)
118
108
} )
119
109
120
110
it ( "Should hash a number" , async ( ) => {
121
- expect ( hash ( 2 ) . toString ( ) ) . toBe (
122
- "113682330006535319932160121224458771213356533826860247409332700812532759386"
123
- )
111
+ expect ( hash ( 2 ) ) . toBe ( "113682330006535319932160121224458771213356533826860247409332700812532759386" )
124
112
} )
125
113
126
114
it ( "Should hash a big number" , async ( ) => {
127
- expect ( hash ( BigInt ( 2 ) ) . toString ( ) ) . toBe (
128
- "113682330006535319932160121224458771213356533826860247409332700812532759386"
129
- )
115
+ expect ( hash ( BigInt ( 2 ) ) ) . toBe ( "113682330006535319932160121224458771213356533826860247409332700812532759386" )
130
116
} )
131
117
132
118
it ( "Should hash an hex number" , async ( ) => {
133
- expect ( hash ( "0x2" ) . toString ( ) ) . toBe (
134
- "113682330006535319932160121224458771213356533826860247409332700812532759386"
135
- )
119
+ expect ( hash ( "0x2" ) ) . toBe ( "113682330006535319932160121224458771213356533826860247409332700812532759386" )
136
120
} )
137
121
138
122
it ( "Should hash an string number" , async ( ) => {
139
- expect ( hash ( "2" ) . toString ( ) ) . toBe (
140
- "113682330006535319932160121224458771213356533826860247409332700812532759386"
141
- )
123
+ expect ( hash ( "2" ) ) . toBe ( "113682330006535319932160121224458771213356533826860247409332700812532759386" )
142
124
} )
143
125
144
126
it ( "Should hash an array" , async ( ) => {
145
- expect ( hash ( [ 2 ] ) . toString ( ) ) . toBe (
146
- "113682330006535319932160121224458771213356533826860247409332700812532759386"
147
- )
127
+ expect ( hash ( [ 2 ] ) ) . toBe ( "113682330006535319932160121224458771213356533826860247409332700812532759386" )
148
128
} )
149
129
} )
150
130
0 commit comments