Skip to content

Commit

Permalink
docs: update quick setup section
Browse files Browse the repository at this point in the history
  • Loading branch information
cedoor committed Mar 4, 2022
1 parent d70ae21 commit 5186a94
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/versioned_docs/version-V2/quick-setup.md
Expand Up @@ -56,7 +56,7 @@ import "@appliedzkp/semaphore-contracts/base/SemaphoreCore.sol";
/// @dev The following code is just a example to show how Semaphore con be used.
contract Greeters is SemaphoreCore {
// A new greeting is published every time a user's proof is validated.
event NewGreeting(string greeting);
event NewGreeting(bytes32 greeting);
// Greeters are identified by a Merkle root.
// The offchain Merkle tree contains the greeters' identity commitments.
Expand All @@ -73,7 +73,7 @@ contract Greeters is SemaphoreCore {
// Only users who create valid proofs can greet.
// The external nullifier is in this example the root of the Merkle tree.
function greet(
string calldata _greeting,
bytes32 _greeting,
uint256 _nullifierHash,
uint256[8] calldata _proof
) external {
Expand Down Expand Up @@ -207,6 +207,7 @@ describe("Greeters", function () {
const identity = new ZkIdentity(Strategy.MESSAGE, message)
const identityCommitment = identity.genIdentityCommitment()
const greeting = "Hello world"
const bytes32Greeting = ethers.utils.formatBytes32String(greeting)

const merkleProof = generateMerkleProof(20, BigInt(0), 2, identityCommitments, identityCommitment)
const witness = Semaphore.genWitness(
Expand All @@ -222,9 +223,9 @@ describe("Greeters", function () {

const nullifierHash = Semaphore.genNullifierHash(merkleProof.root, identity.getNullifier())

const transaction = contract.greet(greeting, nullifierHash, solidityProof)
const transaction = contract.greet(bytes32Greeting, nullifierHash, solidityProof)

await expect(transaction).to.emit(contract, "NewGreeting").withArgs(greeting)
await expect(transaction).to.emit(contract, "NewGreeting").withArgs(bytes32Greeting)
})
})
})
Expand Down

0 comments on commit 5186a94

Please sign in to comment.