Skip to content

Commit a1dc768

Browse files
committed
docs(proof): update usage sections
1 parent 2c08ad2 commit a1dc768

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

packages/core/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,15 @@ yarn add @semaphore-protocol/core
7272

7373
```typescript
7474
import { Identity, Group, generateProof, verifyProof } from "@semaphore-protocol/core"
75-
import { utils } from "ethers"
7675

7776
const identity1 = new Identity()
7877
const identity2 = new Identity()
7978
const identity3 = new Identity()
8079

8180
const group = new Group([identity1.commitment, identity2.commitment, identity3.commitment])
8281

83-
const scope = utils.formatBytes32String("Semaphore")
84-
const message = utils.formatBytes32String("Hello world")
82+
const message = "Hello world"
83+
const scope = "Semaphore"
8584

8685
const proof = await generateProof(identity1, group, message, scope)
8786

packages/proof/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ yarn add @semaphore-protocol/identity @semaphore-protocol/group @semaphore-proto
7373
\# **generateProof**(
7474
identity: _Identity_,
7575
group: _Group_,
76-
message: _BytesLike | Hexable | number | bigint_,
77-
scope: _BytesLike | Hexable | number | bigint_,
76+
message: _BigNumberish_ | _Uint8Array_ | string,
77+
scope: _BigNumberish_ | _Uint8Array_ | string,
7878
merkleTreeDepth: _number_,
7979
snarkArtifacts?: _SnarkArtifacts_
8080
): Promise\<_SemaphoreProof_>
@@ -83,23 +83,23 @@ snarkArtifacts?: _SnarkArtifacts_
8383
import { Identity } from "@semaphore-protocol/identity"
8484
import { Group } from "@semaphore-protocol/group"
8585
import { generateProof } from "@semaphore-protocol/proof"
86-
import { utils } from "ethers"
8786

88-
const identity = new Identity()
89-
const group = new Group()
87+
const identity1 = new Identity()
88+
const identity2 = new Identity()
89+
const identity3 = new Identity()
9090

91-
const scope = utils.formatBytes32String("Topic")
92-
const message = utils.formatBytes32String("Hello world")
91+
const group = new Group([identity1.commitment, identity2.commitment, identity3.commitment])
9392

94-
group.addMembers([...identityCommitments, identity.generateCommitment()])
93+
const message = "Hello world"
94+
const scope = "Semaphore"
9595

96-
const proof1 = await generateProof(identity, group, message, scope)
96+
const proof1 = await generateProof(identity1, group, message, scope)
9797

9898
// You can also specify the maximum tree depth supported by the proof.
99-
const proof2 = await generateProof(identity, group, message, scope, 20)
99+
const proof2 = await generateProof(identity2, group, message, scope, 20)
100100

101101
// You can also specify the default zkey/wasm files.
102-
const proof3 = await generateProof(identity, group, message, scope, 20, {
102+
const proof3 = await generateProof(identity3, group, message, scope, 20, {
103103
wasmFilePath: "./semaphore.wasm",
104104
zkeyFilePath: "./semaphore.zkey"
105105
})

packages/proof/src/generate-proof.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import { BigNumberish, SemaphoreProof, SnarkArtifacts } from "./types"
1111
* Generates a Semaphore proof.
1212
* @param identity The Semaphore identity.
1313
* @param groupOrMerkleProof The Semaphore group or its Merkle proof.
14-
* @param scope The external nullifier.
15-
* @param message The Semaphore signal.
14+
* @param scope The Semaphore scope.
15+
* @param message The Semaphore message.
1616
* @param merkleTreeDepth The depth of the tree with which the circuit was compiled.
1717
* @param snarkArtifacts The SNARK artifacts.
1818
* @returns The Semaphore proof ready to be verified.
1919
*/
2020
export default async function generateProof(
2121
identity: Identity,
2222
groupOrMerkleProof: Group | MerkleProof,
23-
message: BigNumberish | Uint8Array,
24-
scope: BigNumberish | Uint8Array,
23+
message: BigNumberish | Uint8Array | string,
24+
scope: BigNumberish | Uint8Array | string,
2525
merkleTreeDepth?: number,
2626
snarkArtifacts?: SnarkArtifacts
2727
): Promise<SemaphoreProof> {

0 commit comments

Comments
 (0)