1
+ import { BigNumber } from "@ethersproject/bignumber"
2
+ import { BytesLike , Hexable } from "@ethersproject/bytes"
1
3
import { Group } from "@semaphore-protocol/group"
2
4
import type { Identity } from "@semaphore-protocol/identity"
3
- import { prove } from "@zk-kit/groth16"
5
+ import { NumericString , prove } from "@zk-kit/groth16"
4
6
import getSnarkArtifacts from "./get-snark-artifacts.node"
7
+ import hash from "./hash"
5
8
import packProof from "./pack-proof"
6
- import { BigNumberish , SemaphoreProof , SnarkArtifacts } from "./types"
9
+ import { SemaphoreProof , SnarkArtifacts } from "./types"
7
10
8
11
/**
9
12
* Generates a Semaphore proof.
@@ -18,8 +21,8 @@ import { BigNumberish, SemaphoreProof, SnarkArtifacts } from "./types"
18
21
export default async function generateProof (
19
22
identity : Identity ,
20
23
group : Group ,
21
- message : BigNumberish ,
22
- scope : BigNumberish ,
24
+ message : BytesLike | Hexable | number | bigint ,
25
+ scope : BytesLike | Hexable | number | bigint ,
23
26
treeDepth ?: number ,
24
27
snarkArtifacts ?: SnarkArtifacts
25
28
) : Promise < SemaphoreProof > {
@@ -54,8 +57,8 @@ export default async function generateProof(
54
57
treeDepth : merkleProofLength ,
55
58
treeIndices,
56
59
treeSiblings,
57
- scope,
58
- message
60
+ scope : hash ( scope ) ,
61
+ message : hash ( message )
59
62
} ,
60
63
snarkArtifacts . wasmFilePath ,
61
64
snarkArtifacts . zkeyFilePath
@@ -64,8 +67,8 @@ export default async function generateProof(
64
67
return {
65
68
treeRoot : publicSignals [ 0 ] ,
66
69
nullifier : publicSignals [ 1 ] ,
67
- message : publicSignals [ 2 ] ,
68
- scope : publicSignals [ 3 ] ,
70
+ message : BigNumber . from ( message ) . toString ( ) as NumericString ,
71
+ scope : BigNumber . from ( scope ) . toString ( ) as NumericString ,
69
72
proof : packProof ( proof )
70
73
}
71
74
}
0 commit comments