@semaphore-protocol/proof 3.15.1 → 4.0.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Ethereum Foundation
3
+ Copyright (c) 2024 Ethereum Foundation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -72,9 +72,10 @@ yarn add @semaphore-protocol/identity @semaphore-protocol/group @semaphore-proto
72
72
 
73
73
  \# **generateProof**(
74
74
  identity: _Identity_,
75
- group: _Group_ | _MerkleProof_,
76
- externalNullifier: _BytesLike | Hexable | number | bigint_,
77
- signal: _BytesLike | Hexable | number | bigint_,
75
+ group: _Group_,
76
+ message: _BytesLike | Hexable | number | bigint_,
77
+ scope: _BytesLike | Hexable | number | bigint_,
78
+ merkleTreeDepth: _number_,
78
79
  snarkArtifacts?: _SnarkArtifacts_
79
80
  ): Promise\<_SemaphoreProof_>
80
81
 
@@ -86,39 +87,28 @@ import { utils } from "ethers"
86
87
 
87
88
  const identity = new Identity()
88
89
  const group = new Group()
89
- const externalNullifier = utils.formatBytes32String("Topic")
90
- const signal = utils.formatBytes32String("Hello world")
91
90
 
92
- group.addMembers([...identityCommitments, identity.generateCommitment()])
93
-
94
- const fullProof = await generateProof(identity, group, externalNullifier, signal, {
95
- zkeyFilePath: "./semaphore.zkey",
96
- wasmFilePath: "./semaphore.wasm"
97
- })
91
+ const scope = utils.formatBytes32String("Topic")
92
+ const message = utils.formatBytes32String("Hello world")
98
93
 
99
- // You can also use the default zkey/wasm files (it only works from browsers!).
100
- // const fullProof = await generateProof(identity, group, externalNullifier, signal)
101
- ```
94
+ group.addMembers([...identityCommitments, identity.generateCommitment()])
102
95
 
103
- \# **verifyProof**(semaphoreProof: _SemaphoreProof_, treeDepth: _number_): Promise\<_boolean_>
96
+ const fullProof1 = await generateProof(identity, group, message, scope)
104
97
 
105
- ```typescript
106
- import { verifyProof } from "@semaphore-protocol/proof"
98
+ // You can also specify the maximum tree depth supported by the proof.
99
+ const fullProof2 = await generateProof(identity, group, message, scope, 20)
107
100
 
108
- await verifyProof(fullProof, 20)
101
+ // You can also specify the default zkey/wasm files.
102
+ const fullProof3 = await generateProof(identity, group, message, scope, 20, {
103
+ wasmFilePath: "./semaphore.wasm",
104
+ zkeyFilePath: "./semaphore.zkey"
105
+ })
109
106
  ```
110
107
 
111
- \# **calculateNullifierHash**(
112
- identityNullifier: _bigint | number | string_,
113
- externalNullifier: \__BytesLike | Hexable | number | bigint_
114
- ): bigint
108
+ \# **verifyProof**(semaphoreProof: _SemaphoreProof_): Promise\<_boolean_>
115
109
 
116
110
  ```typescript
117
- import { Identity } from "@semaphore-protocol/identity"
118
- import { calculateNullifierHash } from "@semaphore-protocol/proof"
119
-
120
- const identity = new Identity()
121
- const externalNullifier = utils.formatBytes32String("Topic")
111
+ import { verifyProof } from "@semaphore-protocol/proof"
122
112
 
123
- const nullifierHash = calculateNullifierHash(identity.nullifier, externalNullifier)
113
+ await verifyProof(fullProof)
124
114
  ```