1
1
import type { Group , MerkleProof } from "@semaphore-protocol/group"
2
2
import type { Identity } from "@semaphore-protocol/identity"
3
- import { encodeBytes32String , toBigInt } from "ethers"
4
3
import { NumericString , groth16 } from "snarkjs"
5
4
import getSnarkArtifacts from "./get-snark-artifacts.node"
6
5
import hash from "./hash"
7
6
import packPoints from "./pack-points"
8
7
import { BigNumberish , SemaphoreProof , SnarkArtifacts } from "./types"
8
+ import toBigInt from "./to-bigint"
9
9
10
10
/**
11
11
* Generates a Semaphore proof.
@@ -25,25 +25,8 @@ export default async function generateProof(
25
25
merkleTreeDepth ?: number ,
26
26
snarkArtifacts ?: SnarkArtifacts
27
27
) : Promise < SemaphoreProof > {
28
- try {
29
- message = toBigInt ( message )
30
- } catch ( error : any ) {
31
- if ( typeof message === "string" ) {
32
- message = encodeBytes32String ( message )
33
- } else {
34
- throw TypeError ( error . message )
35
- }
36
- }
37
-
38
- try {
39
- scope = toBigInt ( scope )
40
- } catch ( error : any ) {
41
- if ( typeof scope === "string" ) {
42
- scope = encodeBytes32String ( scope )
43
- } else {
44
- throw TypeError ( error . message )
45
- }
46
- }
28
+ message = toBigInt ( message )
29
+ scope = toBigInt ( scope )
47
30
48
31
let merkleProof
49
32
0 commit comments