refactor: rename proof with points

Former-commit-id: 4fcfe5cac1
This commit is contained in:
cedoor
2024-01-24 12:54:26 +00:00
parent a623a5a7b0
commit c6bfadbfa2
35 changed files with 1095 additions and 1052 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,8 @@
{
"sepolia": {
"Semaphore": {
"address": "0x021dC8BF0eADd9C128490A976756C1b052edF99d",
"startBlock": 5108003
"address": "0xb25E63B115Ffba085FeCbf196a8e720F85DC351c",
"startBlock": 5145333
}
},
"mumbai": {

View File

@@ -31,6 +31,6 @@ type ValidatedProof @entity {
merkleTreeRoot: BigInt!
merkleTreeDepth: Int!
nullifier: BigInt!
proof: [BigInt!]!
points: [BigInt!]!
group: Group!
}

View File

@@ -220,7 +220,7 @@ export function addValidatedProof(event: ProofValidated): void {
validatedProof.merkleTreeDepth = event.params.merkleTreeDepth.toI32()
validatedProof.scope = event.params.scope
validatedProof.nullifier = event.params.nullifier
validatedProof.proof = event.params.proof
validatedProof.points = event.params.points
validatedProof.timestamp = event.block.timestamp
validatedProof.save()

View File

@@ -158,7 +158,7 @@ export function createProofVerifiedEvent(
nullifier: BigInt,
message: BigInt,
scope: BigInt,
proof: BigInt[]
points: BigInt[]
): ProofValidated {
const proofValidatedEvent = changetype<ProofValidated>(newMockEvent())
@@ -176,7 +176,9 @@ export function createProofVerifiedEvent(
)
proofValidatedEvent.parameters.push(new ethereum.EventParam("message", ethereum.Value.fromUnsignedBigInt(message)))
proofValidatedEvent.parameters.push(new ethereum.EventParam("scope", ethereum.Value.fromUnsignedBigInt(scope)))
proofValidatedEvent.parameters.push(new ethereum.EventParam("proof", ethereum.Value.fromUnsignedBigIntArray(proof)))
proofValidatedEvent.parameters.push(
new ethereum.EventParam("points", ethereum.Value.fromUnsignedBigIntArray(points))
)
return proofValidatedEvent
}

View File

@@ -162,7 +162,7 @@ describe("Semaphore subgraph", () => {
const nullifier = BigInt.fromI32(666)
const message = BigInt.fromI32(2)
const scope = BigInt.fromI32(1)
const proof = [BigInt.fromI32(1), BigInt.fromI32(2)]
const points = [BigInt.fromI32(1), BigInt.fromI32(2)]
const id = hash(concat(ByteArray.fromBigInt(nullifier), ByteArray.fromBigInt(groupId)))
const event = createProofVerifiedEvent(
@@ -172,7 +172,7 @@ describe("Semaphore subgraph", () => {
nullifier,
message,
scope,
proof
points
)
addValidatedProof(event)
@@ -185,7 +185,7 @@ describe("Semaphore subgraph", () => {
assert.fieldEquals("ValidatedProof", id, "scope", "1")
assert.fieldEquals("ValidatedProof", id, "nullifier", "666")
assert.fieldEquals("ValidatedProof", id, "message", "2")
assert.fieldEquals("ValidatedProof", id, "proof", `[${proof.join(", ")}]`)
assert.fieldEquals("ValidatedProof", id, "points", `[${points.join(", ")}]`)
})
})
})

View File

@@ -24,8 +24,17 @@ contract Feedback {
uint256 merkleTreeRoot,
uint256 nullifier,
uint256 feedback,
uint256[8] calldata proof
uint256[8] calldata points
) external {
semaphore.validateProof(groupId, merkleTreeDepth, merkleTreeRoot, nullifier, feedback, groupId, proof);
ISemaphore.SemaphoreProof memory proof = ISemaphore.SemaphoreProof(
merkleTreeDepth,
merkleTreeRoot,
nullifier,
feedback,
groupId,
points
);
semaphore.validateProof(groupId, proof);
}
}

View File

@@ -52,7 +52,7 @@ describe("Feedback", () => {
fullProof.merkleTreeRoot,
fullProof.nullifier,
feedback,
fullProof.proof
fullProof.points
)
await expect(transaction)
@@ -64,7 +64,7 @@ describe("Feedback", () => {
fullProof.nullifier,
fullProof.message,
groupId,
fullProof.proof
fullProof.points
)
})
})

View File

@@ -24,8 +24,17 @@ contract Feedback {
uint256 merkleTreeRoot,
uint256 nullifier,
uint256 feedback,
uint256[8] calldata proof
uint256[8] calldata points
) external {
semaphore.validateProof(groupId, merkleTreeDepth, merkleTreeRoot, nullifier, feedback, groupId, proof);
ISemaphore.SemaphoreProof memory proof = ISemaphore.SemaphoreProof(
merkleTreeDepth,
merkleTreeRoot,
nullifier,
feedback,
groupId,
points
);
semaphore.validateProof(groupId, proof);
}
}

View File

@@ -52,7 +52,7 @@ describe("Feedback", () => {
fullProof.merkleTreeRoot,
fullProof.nullifier,
feedback,
fullProof.proof
fullProof.points
)
await expect(transaction)
@@ -64,7 +64,7 @@ describe("Feedback", () => {
fullProof.nullifier,
fullProof.message,
groupId,
fullProof.proof
fullProof.points
)
})
})

View File

@@ -1,99 +1,99 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Feedback",
"sourceName": "contracts/Feedback.sol",
"abi": [
"_format": "hh-sol-artifact-1",
"contractName": "Feedback",
"sourceName": "contracts/Feedback.sol",
"abi": [
{
"inputs": [
{
"inputs": [
{
"internalType": "contract ISemaphore",
"name": "_semaphore",
"type": "address"
},
{
"internalType": "uint256",
"name": "_groupId",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
"internalType": "contract ISemaphore",
"name": "_semaphore",
"type": "address"
},
{
"inputs": [],
"name": "groupId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "identityCommitment",
"type": "uint256"
}
],
"name": "joinGroup",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "semaphore",
"outputs": [
{
"internalType": "contract ISemaphore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "merkleTreeDepth",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "merkleTreeRoot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "nullifier",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "feedback",
"type": "uint256"
},
{
"internalType": "uint256[8]",
"name": "proof",
"type": "uint256[8]"
}
],
"name": "sendFeedback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
"internalType": "uint256",
"name": "_groupId",
"type": "uint256"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5060405161072b38038061072b833981810160405281019061003291906101ba565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060018190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c96e71fb600154306040518363ffffffff1660e01b81526004016100d6929190610218565b600060405180830381600087803b1580156100f057600080fd5b505af1158015610104573d6000803e3d6000fd5b505050505050610241565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061013f82610114565b9050919050565b600061015182610134565b9050919050565b61016181610146565b811461016c57600080fd5b50565b60008151905061017e81610158565b92915050565b6000819050919050565b61019781610184565b81146101a257600080fd5b50565b6000815190506101b48161018e565b92915050565b600080604083850312156101d1576101d061010f565b5b60006101df8582860161016f565b92505060206101f0858286016101a5565b9150509250929050565b61020381610184565b82525050565b61021281610134565b82525050565b600060408201905061022d60008301856101fa565b61023a6020830184610209565b9392505050565b6104db806102506000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d2534146100515780637b85d27a1461006f578063a0f44c921461008b578063eed02e4b146100a9575b600080fd5b6100596100c5565b60405161006691906102a2565b60405180910390f35b6100896004803603810190610084919061031f565b6100e9565b005b61009361018b565b6040516100a091906103aa565b60405180910390f35b6100c360048036038101906100be91906103c5565b610191565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632694b47660015487878787600154886040518863ffffffff1660e01b8152600401610152979695949392919061040c565b600060405180830381600087803b15801561016c57600080fd5b505af1158015610180573d6000803e3d6000fd5b505050505050505050565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b81526004016101ee92919061047c565b600060405180830381600087803b15801561020857600080fd5b505af115801561021c573d6000803e3d6000fd5b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061026861026361025e84610223565b610243565b610223565b9050919050565b600061027a8261024d565b9050919050565b600061028c8261026f565b9050919050565b61029c81610281565b82525050565b60006020820190506102b76000830184610293565b92915050565b600080fd5b6000819050919050565b6102d5816102c2565b81146102e057600080fd5b50565b6000813590506102f2816102cc565b92915050565b600080fd5b600081905082602060080282011115610319576103186102f8565b5b92915050565b6000806000806000610180868803121561033c5761033b6102bd565b5b600061034a888289016102e3565b955050602061035b888289016102e3565b945050604061036c888289016102e3565b935050606061037d888289016102e3565b925050608061038e888289016102fd565b9150509295509295909350565b6103a4816102c2565b82525050565b60006020820190506103bf600083018461039b565b92915050565b6000602082840312156103db576103da6102bd565b5b60006103e9848285016102e3565b91505092915050565b82818337505050565b61040861010083836103f2565b5050565b60006101c082019050610422600083018a61039b565b61042f602083018961039b565b61043c604083018861039b565b610449606083018761039b565b610456608083018661039b565b61046360a083018561039b565b61047060c08301846103fb565b98975050505050505050565b6000604082019050610491600083018561039b565b61049e602083018461039b565b939250505056fea26469706673582212204e55122b6afd94ae34af34764263b41bcb463e4fc817ea7ab795705071f8e56f64736f6c63430008170033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d2534146100515780637b85d27a1461006f578063a0f44c921461008b578063eed02e4b146100a9575b600080fd5b6100596100c5565b60405161006691906102a2565b60405180910390f35b6100896004803603810190610084919061031f565b6100e9565b005b61009361018b565b6040516100a091906103aa565b60405180910390f35b6100c360048036038101906100be91906103c5565b610191565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632694b47660015487878787600154886040518863ffffffff1660e01b8152600401610152979695949392919061040c565b600060405180830381600087803b15801561016c57600080fd5b505af1158015610180573d6000803e3d6000fd5b505050505050505050565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b81526004016101ee92919061047c565b600060405180830381600087803b15801561020857600080fd5b505af115801561021c573d6000803e3d6000fd5b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061026861026361025e84610223565b610243565b610223565b9050919050565b600061027a8261024d565b9050919050565b600061028c8261026f565b9050919050565b61029c81610281565b82525050565b60006020820190506102b76000830184610293565b92915050565b600080fd5b6000819050919050565b6102d5816102c2565b81146102e057600080fd5b50565b6000813590506102f2816102cc565b92915050565b600080fd5b600081905082602060080282011115610319576103186102f8565b5b92915050565b6000806000806000610180868803121561033c5761033b6102bd565b5b600061034a888289016102e3565b955050602061035b888289016102e3565b945050604061036c888289016102e3565b935050606061037d888289016102e3565b925050608061038e888289016102fd565b9150509295509295909350565b6103a4816102c2565b82525050565b60006020820190506103bf600083018461039b565b92915050565b6000602082840312156103db576103da6102bd565b5b60006103e9848285016102e3565b91505092915050565b82818337505050565b61040861010083836103f2565b5050565b60006101c082019050610422600083018a61039b565b61042f602083018961039b565b61043c604083018861039b565b610449606083018761039b565b610456608083018661039b565b61046360a083018561039b565b61047060c08301846103fb565b98975050505050505050565b6000604082019050610491600083018561039b565b61049e602083018461039b565b939250505056fea26469706673582212204e55122b6afd94ae34af34764263b41bcb463e4fc817ea7ab795705071f8e56f64736f6c63430008170033",
"linkReferences": {},
"deployedLinkReferences": {}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "groupId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "identityCommitment",
"type": "uint256"
}
],
"name": "joinGroup",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "semaphore",
"outputs": [
{
"internalType": "contract ISemaphore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "merkleTreeDepth",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "merkleTreeRoot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "nullifier",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "feedback",
"type": "uint256"
},
{
"internalType": "uint256[8]",
"name": "points",
"type": "uint256[8]"
}
],
"name": "sendFeedback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b50604051610851380380610851833981810160405281019061003291906101ba565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060018190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c96e71fb600154306040518363ffffffff1660e01b81526004016100d6929190610218565b600060405180830381600087803b1580156100f057600080fd5b505af1158015610104573d6000803e3d6000fd5b505050505050610241565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061013f82610114565b9050919050565b600061015182610134565b9050919050565b61016181610146565b811461016c57600080fd5b50565b60008151905061017e81610158565b92915050565b6000819050919050565b61019781610184565b81146101a257600080fd5b50565b6000815190506101b48161018e565b92915050565b600080604083850312156101d1576101d061010f565b5b60006101df8582860161016f565b92505060206101f0858286016101a5565b9150509250929050565b61020381610184565b82525050565b61021281610134565b82525050565b600060408201905061022d60008301856101fa565b61023a6020830184610209565b9392505050565b610601806102506000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d2534146100515780637b85d27a1461006f578063a0f44c921461008b578063eed02e4b146100a9575b600080fd5b6100596100c5565b6040516100669190610301565b60405180910390f35b6100896004803603810190610084919061037e565b6100e9565b005b6100936101ea565b6040516100a09190610409565b60405180910390f35b6100c360048036038101906100be9190610424565b6101f0565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006040518060c001604052808781526020018681526020018581526020018481526020016001548152602001836008806020026040519081016040528092919082600860200280828437600081840152601f19601f820116905080830192505050505050815250905060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0d898dd600154836040518363ffffffff1660e01b81526004016101b0929190610578565b600060405180830381600087803b1580156101ca57600080fd5b505af11580156101de573d6000803e3d6000fd5b50505050505050505050565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b815260040161024d9291906105a2565b600060405180830381600087803b15801561026757600080fd5b505af115801561027b573d6000803e3d6000fd5b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102c76102c26102bd84610282565b6102a2565b610282565b9050919050565b60006102d9826102ac565b9050919050565b60006102eb826102ce565b9050919050565b6102fb816102e0565b82525050565b600060208201905061031660008301846102f2565b92915050565b600080fd5b6000819050919050565b61033481610321565b811461033f57600080fd5b50565b6000813590506103518161032b565b92915050565b600080fd5b60008190508260206008028201111561037857610377610357565b5b92915050565b6000806000806000610180868803121561039b5761039a61031c565b5b60006103a988828901610342565b95505060206103ba88828901610342565b94505060406103cb88828901610342565b93505060606103dc88828901610342565b92505060806103ed8882890161035c565b9150509295509295909350565b61040381610321565b82525050565b600060208201905061041e60008301846103fa565b92915050565b60006020828403121561043a5761043961031c565b5b600061044884828501610342565b91505092915050565b61045a81610321565b82525050565b600060089050919050565b600081905092915050565b6000819050919050565b600061048c8383610451565b60208301905092915050565b6000602082019050919050565b6104ae81610460565b6104b8818461046b565b92506104c382610476565b8060005b838110156104f45781516104db8782610480565b96506104e683610498565b9250506001810190506104c7565b505050505050565b6101a0820160008201516105136000850182610451565b5060208201516105266020850182610451565b5060408201516105396040850182610451565b50606082015161054c6060850182610451565b50608082015161055f6080850182610451565b5060a082015161057260a08501826104a5565b50505050565b60006101c08201905061058e60008301856103fa565b61059b60208301846104fc565b9392505050565b60006040820190506105b760008301856103fa565b6105c460208301846103fa565b939250505056fea26469706673582212208d1f71499c8710ebb4fc00256397c0764cbf05c24c0a365e44aa27667881cde864736f6c63430008170033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d2534146100515780637b85d27a1461006f578063a0f44c921461008b578063eed02e4b146100a9575b600080fd5b6100596100c5565b6040516100669190610301565b60405180910390f35b6100896004803603810190610084919061037e565b6100e9565b005b6100936101ea565b6040516100a09190610409565b60405180910390f35b6100c360048036038101906100be9190610424565b6101f0565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006040518060c001604052808781526020018681526020018581526020018481526020016001548152602001836008806020026040519081016040528092919082600860200280828437600081840152601f19601f820116905080830192505050505050815250905060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0d898dd600154836040518363ffffffff1660e01b81526004016101b0929190610578565b600060405180830381600087803b1580156101ca57600080fd5b505af11580156101de573d6000803e3d6000fd5b50505050505050505050565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b815260040161024d9291906105a2565b600060405180830381600087803b15801561026757600080fd5b505af115801561027b573d6000803e3d6000fd5b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102c76102c26102bd84610282565b6102a2565b610282565b9050919050565b60006102d9826102ac565b9050919050565b60006102eb826102ce565b9050919050565b6102fb816102e0565b82525050565b600060208201905061031660008301846102f2565b92915050565b600080fd5b6000819050919050565b61033481610321565b811461033f57600080fd5b50565b6000813590506103518161032b565b92915050565b600080fd5b60008190508260206008028201111561037857610377610357565b5b92915050565b6000806000806000610180868803121561039b5761039a61031c565b5b60006103a988828901610342565b95505060206103ba88828901610342565b94505060406103cb88828901610342565b93505060606103dc88828901610342565b92505060806103ed8882890161035c565b9150509295509295909350565b61040381610321565b82525050565b600060208201905061041e60008301846103fa565b92915050565b60006020828403121561043a5761043961031c565b5b600061044884828501610342565b91505092915050565b61045a81610321565b82525050565b600060089050919050565b600081905092915050565b6000819050919050565b600061048c8383610451565b60208301905092915050565b6000602082019050919050565b6104ae81610460565b6104b8818461046b565b92506104c382610476565b8060005b838110156104f45781516104db8782610480565b96506104e683610498565b9250506001810190506104c7565b505050505050565b6101a0820160008201516105136000850182610451565b5060208201516105266020850182610451565b5060408201516105396040850182610451565b50606082015161054c6060850182610451565b50608082015161055f6080850182610451565b5060a082015161057260a08501826104a5565b50505050565b60006101c08201905061058e60008301856103fa565b61059b60208301846104fc565b9392505050565b60006040820190506105b760008301856103fa565b6105c460208301846103fa565b939250505056fea26469706673582212208d1f71499c8710ebb4fc00256397c0764cbf05c24c0a365e44aa27667881cde864736f6c63430008170033",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -30,10 +30,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const signer = new Wallet(ethereumPrivateKey, provider)
const contract = new Contract(contractAddress, Feedback.abi, signer)
const { feedback, merkleTreeDepth, merkleTreeRoot, nullifier, proof } = req.body
const { feedback, merkleTreeDepth, merkleTreeRoot, nullifier, points } = req.body
try {
const transaction = await contract.sendFeedback(merkleTreeDepth, merkleTreeRoot, nullifier, feedback, proof)
const transaction = await contract.sendFeedback(merkleTreeDepth, merkleTreeRoot, nullifier, feedback, points)
await transaction.wait()

View File

@@ -55,7 +55,7 @@ export default function ProofsPage() {
group.addMembers(_users)
const { proof, merkleTreeDepth, merkleTreeRoot, nullifier } = await generateProof(
const { points, merkleTreeDepth, merkleTreeRoot, nullifier } = await generateProof(
_identity,
group,
message,
@@ -72,7 +72,7 @@ export default function ProofsPage() {
abi: Feedback.abi,
address: env.FEEDBACK_CONTRACT_ADDRESS,
functionName: "sendFeedback",
functionParameters: [merkleTreeDepth, merkleTreeRoot, nullifier, message, proof]
functionParameters: [merkleTreeDepth, merkleTreeRoot, nullifier, message, points]
})
})
} else {
@@ -84,7 +84,7 @@ export default function ProofsPage() {
merkleTreeDepth,
merkleTreeRoot,
nullifier,
proof
points
})
})
}

View File

@@ -24,8 +24,17 @@ contract Feedback {
uint256 merkleTreeRoot,
uint256 nullifier,
uint256 feedback,
uint256[8] calldata proof
uint256[8] calldata points
) external {
semaphore.validateProof(groupId, merkleTreeDepth, merkleTreeRoot, nullifier, feedback, groupId, proof);
ISemaphore.SemaphoreProof memory proof = ISemaphore.SemaphoreProof(
merkleTreeDepth,
merkleTreeRoot,
nullifier,
feedback,
groupId,
points
);
semaphore.validateProof(groupId, proof);
}
}

View File

@@ -52,7 +52,7 @@ describe("Feedback", () => {
fullProof.merkleTreeRoot,
fullProof.nullifier,
feedback,
fullProof.proof
fullProof.points
)
await expect(transaction)
@@ -64,7 +64,7 @@ describe("Feedback", () => {
fullProof.nullifier,
fullProof.message,
groupId,
fullProof.proof
fullProof.points
)
})
})

View File

@@ -1,99 +1,99 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Feedback",
"sourceName": "contracts/Feedback.sol",
"abi": [
"_format": "hh-sol-artifact-1",
"contractName": "Feedback",
"sourceName": "contracts/Feedback.sol",
"abi": [
{
"inputs": [
{
"inputs": [
{
"internalType": "contract ISemaphore",
"name": "_semaphore",
"type": "address"
},
{
"internalType": "uint256",
"name": "_groupId",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
"internalType": "contract ISemaphore",
"name": "_semaphore",
"type": "address"
},
{
"inputs": [],
"name": "groupId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "identityCommitment",
"type": "uint256"
}
],
"name": "joinGroup",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "semaphore",
"outputs": [
{
"internalType": "contract ISemaphore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "merkleTreeDepth",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "merkleTreeRoot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "nullifier",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "feedback",
"type": "uint256"
},
{
"internalType": "uint256[8]",
"name": "proof",
"type": "uint256[8]"
}
],
"name": "sendFeedback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
"internalType": "uint256",
"name": "_groupId",
"type": "uint256"
}
],
"bytecode": "0x608060405234801561001057600080fd5b5060405161072b38038061072b833981810160405281019061003291906101ba565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060018190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c96e71fb600154306040518363ffffffff1660e01b81526004016100d6929190610218565b600060405180830381600087803b1580156100f057600080fd5b505af1158015610104573d6000803e3d6000fd5b505050505050610241565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061013f82610114565b9050919050565b600061015182610134565b9050919050565b61016181610146565b811461016c57600080fd5b50565b60008151905061017e81610158565b92915050565b6000819050919050565b61019781610184565b81146101a257600080fd5b50565b6000815190506101b48161018e565b92915050565b600080604083850312156101d1576101d061010f565b5b60006101df8582860161016f565b92505060206101f0858286016101a5565b9150509250929050565b61020381610184565b82525050565b61021281610134565b82525050565b600060408201905061022d60008301856101fa565b61023a6020830184610209565b9392505050565b6104db806102506000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d2534146100515780637b85d27a1461006f578063a0f44c921461008b578063eed02e4b146100a9575b600080fd5b6100596100c5565b60405161006691906102a2565b60405180910390f35b6100896004803603810190610084919061031f565b6100e9565b005b61009361018b565b6040516100a091906103aa565b60405180910390f35b6100c360048036038101906100be91906103c5565b610191565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632694b47660015487878787600154886040518863ffffffff1660e01b8152600401610152979695949392919061040c565b600060405180830381600087803b15801561016c57600080fd5b505af1158015610180573d6000803e3d6000fd5b505050505050505050565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b81526004016101ee92919061047c565b600060405180830381600087803b15801561020857600080fd5b505af115801561021c573d6000803e3d6000fd5b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061026861026361025e84610223565b610243565b610223565b9050919050565b600061027a8261024d565b9050919050565b600061028c8261026f565b9050919050565b61029c81610281565b82525050565b60006020820190506102b76000830184610293565b92915050565b600080fd5b6000819050919050565b6102d5816102c2565b81146102e057600080fd5b50565b6000813590506102f2816102cc565b92915050565b600080fd5b600081905082602060080282011115610319576103186102f8565b5b92915050565b6000806000806000610180868803121561033c5761033b6102bd565b5b600061034a888289016102e3565b955050602061035b888289016102e3565b945050604061036c888289016102e3565b935050606061037d888289016102e3565b925050608061038e888289016102fd565b9150509295509295909350565b6103a4816102c2565b82525050565b60006020820190506103bf600083018461039b565b92915050565b6000602082840312156103db576103da6102bd565b5b60006103e9848285016102e3565b91505092915050565b82818337505050565b61040861010083836103f2565b5050565b60006101c082019050610422600083018a61039b565b61042f602083018961039b565b61043c604083018861039b565b610449606083018761039b565b610456608083018661039b565b61046360a083018561039b565b61047060c08301846103fb565b98975050505050505050565b6000604082019050610491600083018561039b565b61049e602083018461039b565b939250505056fea26469706673582212204e55122b6afd94ae34af34764263b41bcb463e4fc817ea7ab795705071f8e56f64736f6c63430008170033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d2534146100515780637b85d27a1461006f578063a0f44c921461008b578063eed02e4b146100a9575b600080fd5b6100596100c5565b60405161006691906102a2565b60405180910390f35b6100896004803603810190610084919061031f565b6100e9565b005b61009361018b565b6040516100a091906103aa565b60405180910390f35b6100c360048036038101906100be91906103c5565b610191565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632694b47660015487878787600154886040518863ffffffff1660e01b8152600401610152979695949392919061040c565b600060405180830381600087803b15801561016c57600080fd5b505af1158015610180573d6000803e3d6000fd5b505050505050505050565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b81526004016101ee92919061047c565b600060405180830381600087803b15801561020857600080fd5b505af115801561021c573d6000803e3d6000fd5b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061026861026361025e84610223565b610243565b610223565b9050919050565b600061027a8261024d565b9050919050565b600061028c8261026f565b9050919050565b61029c81610281565b82525050565b60006020820190506102b76000830184610293565b92915050565b600080fd5b6000819050919050565b6102d5816102c2565b81146102e057600080fd5b50565b6000813590506102f2816102cc565b92915050565b600080fd5b600081905082602060080282011115610319576103186102f8565b5b92915050565b6000806000806000610180868803121561033c5761033b6102bd565b5b600061034a888289016102e3565b955050602061035b888289016102e3565b945050604061036c888289016102e3565b935050606061037d888289016102e3565b925050608061038e888289016102fd565b9150509295509295909350565b6103a4816102c2565b82525050565b60006020820190506103bf600083018461039b565b92915050565b6000602082840312156103db576103da6102bd565b5b60006103e9848285016102e3565b91505092915050565b82818337505050565b61040861010083836103f2565b5050565b60006101c082019050610422600083018a61039b565b61042f602083018961039b565b61043c604083018861039b565b610449606083018761039b565b610456608083018661039b565b61046360a083018561039b565b61047060c08301846103fb565b98975050505050505050565b6000604082019050610491600083018561039b565b61049e602083018461039b565b939250505056fea26469706673582212204e55122b6afd94ae34af34764263b41bcb463e4fc817ea7ab795705071f8e56f64736f6c63430008170033",
"linkReferences": {},
"deployedLinkReferences": {}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "groupId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "identityCommitment",
"type": "uint256"
}
],
"name": "joinGroup",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "semaphore",
"outputs": [
{
"internalType": "contract ISemaphore",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "merkleTreeDepth",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "merkleTreeRoot",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "nullifier",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "feedback",
"type": "uint256"
},
{
"internalType": "uint256[8]",
"name": "points",
"type": "uint256[8]"
}
],
"name": "sendFeedback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b50604051610851380380610851833981810160405281019061003291906101ba565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060018190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c96e71fb600154306040518363ffffffff1660e01b81526004016100d6929190610218565b600060405180830381600087803b1580156100f057600080fd5b505af1158015610104573d6000803e3d6000fd5b505050505050610241565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061013f82610114565b9050919050565b600061015182610134565b9050919050565b61016181610146565b811461016c57600080fd5b50565b60008151905061017e81610158565b92915050565b6000819050919050565b61019781610184565b81146101a257600080fd5b50565b6000815190506101b48161018e565b92915050565b600080604083850312156101d1576101d061010f565b5b60006101df8582860161016f565b92505060206101f0858286016101a5565b9150509250929050565b61020381610184565b82525050565b61021281610134565b82525050565b600060408201905061022d60008301856101fa565b61023a6020830184610209565b9392505050565b610601806102506000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d2534146100515780637b85d27a1461006f578063a0f44c921461008b578063eed02e4b146100a9575b600080fd5b6100596100c5565b6040516100669190610301565b60405180910390f35b6100896004803603810190610084919061037e565b6100e9565b005b6100936101ea565b6040516100a09190610409565b60405180910390f35b6100c360048036038101906100be9190610424565b6101f0565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006040518060c001604052808781526020018681526020018581526020018481526020016001548152602001836008806020026040519081016040528092919082600860200280828437600081840152601f19601f820116905080830192505050505050815250905060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0d898dd600154836040518363ffffffff1660e01b81526004016101b0929190610578565b600060405180830381600087803b1580156101ca57600080fd5b505af11580156101de573d6000803e3d6000fd5b50505050505050505050565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b815260040161024d9291906105a2565b600060405180830381600087803b15801561026757600080fd5b505af115801561027b573d6000803e3d6000fd5b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102c76102c26102bd84610282565b6102a2565b610282565b9050919050565b60006102d9826102ac565b9050919050565b60006102eb826102ce565b9050919050565b6102fb816102e0565b82525050565b600060208201905061031660008301846102f2565b92915050565b600080fd5b6000819050919050565b61033481610321565b811461033f57600080fd5b50565b6000813590506103518161032b565b92915050565b600080fd5b60008190508260206008028201111561037857610377610357565b5b92915050565b6000806000806000610180868803121561039b5761039a61031c565b5b60006103a988828901610342565b95505060206103ba88828901610342565b94505060406103cb88828901610342565b93505060606103dc88828901610342565b92505060806103ed8882890161035c565b9150509295509295909350565b61040381610321565b82525050565b600060208201905061041e60008301846103fa565b92915050565b60006020828403121561043a5761043961031c565b5b600061044884828501610342565b91505092915050565b61045a81610321565b82525050565b600060089050919050565b600081905092915050565b6000819050919050565b600061048c8383610451565b60208301905092915050565b6000602082019050919050565b6104ae81610460565b6104b8818461046b565b92506104c382610476565b8060005b838110156104f45781516104db8782610480565b96506104e683610498565b9250506001810190506104c7565b505050505050565b6101a0820160008201516105136000850182610451565b5060208201516105266020850182610451565b5060408201516105396040850182610451565b50606082015161054c6060850182610451565b50608082015161055f6080850182610451565b5060a082015161057260a08501826104a5565b50505050565b60006101c08201905061058e60008301856103fa565b61059b60208301846104fc565b9392505050565b60006040820190506105b760008301856103fa565b6105c460208301846103fa565b939250505056fea26469706673582212208d1f71499c8710ebb4fc00256397c0764cbf05c24c0a365e44aa27667881cde864736f6c63430008170033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80637b5d2534146100515780637b85d27a1461006f578063a0f44c921461008b578063eed02e4b146100a9575b600080fd5b6100596100c5565b6040516100669190610301565b60405180910390f35b6100896004803603810190610084919061037e565b6100e9565b005b6100936101ea565b6040516100a09190610409565b60405180910390f35b6100c360048036038101906100be9190610424565b6101f0565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006040518060c001604052808781526020018681526020018581526020018481526020016001548152602001836008806020026040519081016040528092919082600860200280828437600081840152601f19601f820116905080830192505050505050815250905060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0d898dd600154836040518363ffffffff1660e01b81526004016101b0929190610578565b600060405180830381600087803b1580156101ca57600080fd5b505af11580156101de573d6000803e3d6000fd5b50505050505050505050565b60015481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631783efc3600154836040518363ffffffff1660e01b815260040161024d9291906105a2565b600060405180830381600087803b15801561026757600080fd5b505af115801561027b573d6000803e3d6000fd5b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006102c76102c26102bd84610282565b6102a2565b610282565b9050919050565b60006102d9826102ac565b9050919050565b60006102eb826102ce565b9050919050565b6102fb816102e0565b82525050565b600060208201905061031660008301846102f2565b92915050565b600080fd5b6000819050919050565b61033481610321565b811461033f57600080fd5b50565b6000813590506103518161032b565b92915050565b600080fd5b60008190508260206008028201111561037857610377610357565b5b92915050565b6000806000806000610180868803121561039b5761039a61031c565b5b60006103a988828901610342565b95505060206103ba88828901610342565b94505060406103cb88828901610342565b93505060606103dc88828901610342565b92505060806103ed8882890161035c565b9150509295509295909350565b61040381610321565b82525050565b600060208201905061041e60008301846103fa565b92915050565b60006020828403121561043a5761043961031c565b5b600061044884828501610342565b91505092915050565b61045a81610321565b82525050565b600060089050919050565b600081905092915050565b6000819050919050565b600061048c8383610451565b60208301905092915050565b6000602082019050919050565b6104ae81610460565b6104b8818461046b565b92506104c382610476565b8060005b838110156104f45781516104db8782610480565b96506104e683610498565b9250506001810190506104c7565b505050505050565b6101a0820160008201516105136000850182610451565b5060208201516105266020850182610451565b5060408201516105396040850182610451565b50606082015161054c6060850182610451565b50608082015161055f6080850182610451565b5060a082015161057260a08501826104a5565b50505050565b60006101c08201905061058e60008301856103fa565b61059b60208301846104fc565b9392505050565b60006040820190506105b760008301856103fa565b6105c460208301846103fa565b939250505056fea26469706673582212208d1f71499c8710ebb4fc00256397c0764cbf05c24c0a365e44aa27667881cde864736f6c63430008170033",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@@ -30,10 +30,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const signer = new Wallet(ethereumPrivateKey, provider)
const contract = new Contract(contractAddress, Feedback.abi, signer)
const { feedback, merkleTreeDepth, merkleTreeRoot, nullifier, proof } = req.body
const { feedback, merkleTreeDepth, merkleTreeRoot, nullifier, points } = req.body
try {
const transaction = await contract.sendFeedback(merkleTreeDepth, merkleTreeRoot, nullifier, feedback, proof)
const transaction = await contract.sendFeedback(merkleTreeDepth, merkleTreeRoot, nullifier, feedback, points)
await transaction.wait()

View File

@@ -1,6 +1,7 @@
import { Group } from "@semaphore-protocol/group"
import { Identity } from "@semaphore-protocol/identity"
import { generateProof } from "@semaphore-protocol/proof"
import { encodeBytes32String } from "ethers"
import getNextConfig from "next/config"
import { useRouter } from "next/router"
import { useCallback, useContext, useEffect, useState } from "react"
@@ -8,7 +9,6 @@ import Feedback from "../../contract-artifacts/Feedback.json"
import Stepper from "../components/Stepper"
import LogsContext from "../context/LogsContext"
import SemaphoreContext from "../context/SemaphoreContext"
import { encodeBytes32String } from "ethers"
const { publicRuntimeConfig: env } = getNextConfig()
@@ -55,7 +55,7 @@ export default function ProofsPage() {
group.addMembers(_users)
const { proof, merkleTreeDepth, merkleTreeRoot, nullifier } = await generateProof(
const { points, merkleTreeDepth, merkleTreeRoot, nullifier } = await generateProof(
_identity,
group,
message,
@@ -72,7 +72,7 @@ export default function ProofsPage() {
abi: Feedback.abi,
address: env.FEEDBACK_CONTRACT_ADDRESS,
functionName: "sendFeedback",
functionParameters: [merkleTreeDepth, merkleTreeRoot, nullifier, message, proof]
functionParameters: [merkleTreeDepth, merkleTreeRoot, nullifier, message, points]
})
})
} else {
@@ -84,7 +84,7 @@ export default function ProofsPage() {
merkleTreeDepth,
merkleTreeRoot,
nullifier,
proof
points
})
})
}

View File

@@ -341,8 +341,8 @@ program
const content = `${chalk.bold("Proofs")} (${validatedProofs.length}): \n${validatedProofs
.map(
({ message, merkleTreeRoot, merkleTreeDepth, scope, nullifier, proof }: any, i: number) =>
` ${i}. message: ${message} \n merkleTreeRoot: ${merkleTreeRoot} \n merkleTreeDepth: ${merkleTreeDepth} \n scope: ${scope} \n nullifier: ${nullifier} \n proof: [${proof.join(
({ message, merkleTreeRoot, merkleTreeDepth, scope, nullifier, points }: any, i: number) =>
` ${i}. message: ${message} \n merkleTreeRoot: ${merkleTreeRoot} \n merkleTreeDepth: ${merkleTreeDepth} \n scope: ${scope} \n nullifier: ${nullifier} \n points: [${points.join(
", "
)}]`
)

View File

@@ -121,7 +121,7 @@ contract Semaphore is ISemaphore, SemaphoreGroups {
proof.nullifier,
proof.message,
proof.scope,
proof.proof
proof.points
);
}
@@ -158,9 +158,9 @@ contract Semaphore is ISemaphore, SemaphoreGroups {
return
verifier.verifyProof(
[proof.proof[0], proof.proof[1]],
[[proof.proof[2], proof.proof[3]], [proof.proof[4], proof.proof[5]]],
[proof.proof[6], proof.proof[7]],
[proof.points[0], proof.points[1]],
[[proof.points[2], proof.points[3]], [proof.points[4], proof.points[5]]],
[proof.points[6], proof.points[7]],
[proof.merkleTreeRoot, proof.nullifier, _hash(proof.message), _hash(proof.scope)],
proof.merkleTreeDepth
);

View File

@@ -24,7 +24,7 @@ interface ISemaphore {
uint256 nullifier;
uint256 message;
uint256 scope;
uint256[8] proof;
uint256[8] points;
}
/// @dev Emitted when the Merkle tree duration of a group is updated.
@@ -44,7 +44,7 @@ interface ISemaphore {
/// @param nullifier: Nullifier.
/// @param message: Semaphore message.
/// @param scope: Scope.
/// @param proof: Zero-knowledge proof.
/// @param points: Zero-knowledge points.
event ProofValidated(
uint256 indexed groupId,
uint256 merkleTreeDepth,
@@ -52,7 +52,7 @@ interface ISemaphore {
uint256 nullifier,
uint256 message,
uint256 indexed scope,
uint256[8] proof
uint256[8] points
);
/// @dev See {SemaphoreGroups-_createGroup}.

View File

@@ -1,5 +1,5 @@
{
"Verifier": "0xbFc3F24cB7fa3285cd403C66925961991757780e",
"Poseidon": "0xbdC436c93B3a71A6ac97E0Cd8b82AdaEf942D9d7",
"Semaphore": "0x021dC8BF0eADd9C128490A976756C1b052edF99d"
"Verifier": "0xf2e44cC007f0c0965875dB77152a757159e4507D",
"Poseidon": "0x31cF407EA3964c092F9E171D3692e9B7466288ca",
"Semaphore": "0xb25E63B115Ffba085FeCbf196a8e720F85DC351c"
}

View File

@@ -307,12 +307,12 @@ describe("Semaphore", () => {
.to.emit(semaphoreContract, "ProofValidated")
.withArgs(
groupOneMemberId,
fullProof.merkleTreeDepth,
fullProofOneMember.merkleTreeDepth,
fullProofOneMember.merkleTreeRoot,
fullProofOneMember.nullifier,
fullProofOneMember.message,
fullProofOneMember.merkleTreeRoot,
fullProofOneMember.proof
fullProofOneMember.points
)
})
@@ -328,7 +328,7 @@ describe("Semaphore", () => {
fullProof.nullifier,
fullProof.message,
fullProof.merkleTreeRoot,
fullProof.proof
fullProof.points
)
})

View File

@@ -55,8 +55,8 @@ export default class SemaphoreEthers {
options.startBlock ??= 33995010
break
case "sepolia":
options.address ??= "0x021dC8BF0eADd9C128490A976756C1b052edF99d"
options.startBlock ??= 5108003
options.address ??= "0xb25E63B115Ffba085FeCbf196a8e720F85DC351c"
options.startBlock ??= 5145333
break
case "optimism-sepolia":
options.address ??= "0x3889927F0B5Eb1a02C6E2C20b39a1Bd4EAd76131"
@@ -301,7 +301,7 @@ export default class SemaphoreEthers {
nullifier: event[3].toString(),
message: event[4].toString(),
scope: event[5].toString(),
proof: event[6].map((p: any) => p.toString())
points: event[6].map((p: any) => p.toString())
}))
}

View File

@@ -12,7 +12,7 @@ export default function getURL(supportedNetwork: SupportedNetwork | string): str
case "optimism-sepolia":
case "arbitrum-sepolia":
case "arbitrum":
return `https://api.studio.thegraph.com/query/14377/semaphore-${supportedNetwork}/v4.0.0-alpha.2`
return `https://api.studio.thegraph.com/query/14377/semaphore-${supportedNetwork}/v4.0.0-alpha.3`
default:
throw new TypeError(`Network '${supportedNetwork}' is not supported`)
}

View File

@@ -120,7 +120,7 @@ export default class SemaphoreSubgraph {
merkleTreeDepth
scope
nullifier
proof
points
timestamp
}`
: ""
@@ -183,7 +183,7 @@ export default class SemaphoreSubgraph {
merkleTreeDepth
scope
nullifier
proof
points
timestamp
}`
: ""

View File

@@ -44,7 +44,7 @@ export type GroupResponse = {
merkleTreeDepth: number
scope: string
nullifier: string
proof: string[]
points: string[]
timestamp?: string
}[]
}

View File

@@ -129,7 +129,7 @@ describe("SemaphoreSubgraph", () => {
merkleTreeDepth: "32",
scope: "14324",
nullifier: "442342",
proof: ["442342"],
points: ["442342"],
timestamp: "1657306917"
},
{
@@ -138,7 +138,7 @@ describe("SemaphoreSubgraph", () => {
merkleTreeDepth: "32",
scope: "14324",
nullifier: "442342",
proof: ["442342"],
points: ["442342"],
timestamp: "1657306923"
}
]
@@ -170,7 +170,7 @@ describe("SemaphoreSubgraph", () => {
merkleTreeDepth: "32",
scope: "14324",
nullifier: "442342",
proof: ["442342"],
points: ["442342"],
timestamp: "1657306917"
},
{
@@ -179,7 +179,7 @@ describe("SemaphoreSubgraph", () => {
merkleTreeDepth: "32",
scope: "14324",
nullifier: "442342",
proof: ["442342"],
points: ["442342"],
timestamp: "1657306923"
}
]
@@ -289,7 +289,7 @@ describe("SemaphoreSubgraph", () => {
merkleTreeDepth: "32",
scope: "14324",
nullifier: "442342",
proof: ["442342"],
points: ["442342"],
timestamp: "1657306917"
},
{
@@ -298,7 +298,7 @@ describe("SemaphoreSubgraph", () => {
merkleTreeDepth: "32",
scope: "14324",
nullifier: "442342",
proof: ["442342"],
points: ["442342"],
timestamp: "1657306923"
}
]
@@ -329,7 +329,7 @@ describe("SemaphoreSubgraph", () => {
merkleTreeDepth: "32",
scope: "14324",
nullifier: "442342",
proof: ["442342"],
points: ["442342"],
timestamp: "1657306917"
},
{
@@ -338,7 +338,7 @@ describe("SemaphoreSubgraph", () => {
merkleTreeDepth: "32",
scope: "14324",
nullifier: "442342",
proof: ["442342"],
points: ["442342"],
timestamp: "1657306923"
}
]

View File

@@ -5,7 +5,7 @@ import type { Identity } from "@semaphore-protocol/identity"
import { NumericString, prove } from "@zk-kit/groth16"
import getSnarkArtifacts from "./get-snark-artifacts.node"
import hash from "./hash"
import packProof from "./pack-proof"
import packPoints from "./pack-proof"
import { SemaphoreProof, SnarkArtifacts } from "./types"
/**
@@ -76,6 +76,6 @@ export default async function generateProof(
nullifier: publicSignals[1],
message: BigNumber.from(message).toString() as NumericString,
scope: BigNumber.from(scope).toString() as NumericString,
proof: packProof(proof)
points: packPoints(proof)
}
}

View File

@@ -1,8 +1,8 @@
import generateProof from "./generate-proof"
import getSnarkArtifacts from "./get-snark-artifacts.node"
import packProof from "./pack-proof"
import unpackProof from "./unpack-proof"
import packPoints from "./pack-proof"
import unpackPoints from "./unpack-proof"
import verifyProof from "./verify-proof"
export * from "./types"
export { generateProof, getSnarkArtifacts, packProof, unpackProof, verifyProof }
export { generateProof, getSnarkArtifacts, packPoints, unpackPoints, verifyProof }

View File

@@ -1,12 +1,12 @@
import { Groth16Proof } from "@zk-kit/groth16"
import { PackedProof } from "./types"
import { PackedPoints } from "./types"
/**
* Packs a proof into a format compatible with Semaphore.
* @param proof The Groth16 proof generated with SnarkJS.
* @returns The proof compatible with Semaphore.
* Packs the Groth16 proof points into a format compatible with Semaphore.
* @param proof The proof points generated with SnarkJS.
* @returns The proof points compatible with Semaphore.
*/
export default function packProof(proof: Groth16Proof): PackedProof {
export default function packPoints(proof: Groth16Proof): PackedPoints {
return [
proof.pi_a[0],
proof.pi_a[1],

View File

@@ -13,10 +13,10 @@ export type SemaphoreProof = {
message: NumericString
nullifier: NumericString
scope: NumericString
proof: PackedProof
points: PackedPoints
}
export type PackedProof = [
export type PackedPoints = [
NumericString,
NumericString,
NumericString,

View File

@@ -1,12 +1,12 @@
import { Groth16Proof } from "@zk-kit/groth16"
import { PackedProof } from "./types"
import { PackedPoints } from "./types"
/**
* Unpacks a proof into its original form.
* @param proof The proof compatible with Semaphore.
* @returns The proof compatible with SnarkJS.
* Unpacks the Groth16 proof points into their original form.
* @param proof The proof points compatible with Semaphore.
* @returns The proof points compatible with SnarkJS.
*/
export default function unpackProof(proof: PackedProof): Groth16Proof {
export default function unpackPoints(proof: PackedPoints): Groth16Proof {
return {
pi_a: [proof[0], proof[1]],
pi_b: [

View File

@@ -1,8 +1,8 @@
import { verify } from "@zk-kit/groth16"
import { SemaphoreProof } from "./types"
import unpackProof from "./unpack-proof"
import verificationKeys from "./verification-keys.json"
import hash from "./hash"
import { SemaphoreProof } from "./types"
import unpackPoints from "./unpack-proof"
import verificationKeys from "./verification-keys.json"
/**
* Verifies a Semaphore proof.
@@ -16,7 +16,7 @@ export default async function verifyProof({
nullifier,
message,
scope,
proof
points
}: SemaphoreProof): Promise<boolean> {
// TODO: support all tree depths after trusted-setup.
if (merkleTreeDepth < 1 || merkleTreeDepth > 12) {
@@ -31,6 +31,6 @@ export default async function verifyProof({
return verify(verificationKey, {
publicSignals: [merkleTreeRoot, nullifier, hash(message), hash(scope)],
proof: unpackProof(proof)
proof: unpackPoints(points)
})
}

View File

@@ -2,7 +2,7 @@ import { formatBytes32String } from "@ethersproject/strings"
import { Group } from "@semaphore-protocol/group"
import { Identity } from "@semaphore-protocol/identity"
import { getCurveFromName } from "ffjavascript"
import { SemaphoreProof, generateProof, packProof, unpackProof, verifyProof } from "../src"
import { SemaphoreProof, generateProof, packPoints, unpackPoints, verifyProof } from "../src"
describe("Proof", () => {
const treeDepth = 10
@@ -66,10 +66,10 @@ describe("Proof", () => {
describe("# packProof/unpackProof", () => {
it("Should return a packed proof", async () => {
const originalProof = unpackProof(fullProof.proof)
const proof = packProof(originalProof)
const originalProof = unpackPoints(fullProof.points)
const proof = packPoints(originalProof)
expect(proof).toStrictEqual(fullProof.proof)
expect(proof).toStrictEqual(fullProof.points)
})
})
})