Skip to content

Commit

Permalink
refactor: rename proof with points
Browse files Browse the repository at this point in the history
  • Loading branch information
cedoor committed Jan 24, 2024
1 parent 8845d89 commit fbc8efd
Show file tree
Hide file tree
Showing 35 changed files with 1,070 additions and 1,027 deletions.
1,546 changes: 780 additions & 766 deletions apps/subgraph/abis/Semaphore.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/subgraph/networks.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"sepolia": {
"Semaphore": {
"address": "0x021dC8BF0eADd9C128490A976756C1b052edF99d",
"startBlock": 5108003
"address": "0xb25E63B115Ffba085FeCbf196a8e720F85DC351c",
"startBlock": 5145333
}
},
"mumbai": {
Expand Down
2 changes: 1 addition & 1 deletion apps/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ type ValidatedProof @entity {
merkleTreeRoot: BigInt!
merkleTreeDepth: Int!
nullifier: BigInt!
proof: [BigInt!]!
points: [BigInt!]!
group: Group!
}
2 changes: 1 addition & 1 deletion apps/subgraph/src/semaphore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions apps/subgraph/tests/semaphore-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function createProofVerifiedEvent(
nullifier: BigInt,
message: BigInt,
scope: BigInt,
proof: BigInt[]
points: BigInt[]
): ProofValidated {
const proofValidatedEvent = changetype<ProofValidated>(newMockEvent())

Expand All @@ -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
}
6 changes: 3 additions & 3 deletions apps/subgraph/tests/semaphore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -172,7 +172,7 @@ describe("Semaphore subgraph", () => {
nullifier,
message,
scope,
proof
points
)

addValidatedProof(event)
Expand All @@ -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(", ")}]`)
})
})
})
13 changes: 11 additions & 2 deletions packages/cli-template-contracts-hardhat/contracts/Feedback.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions packages/cli-template-contracts-hardhat/test/Feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Feedback", () => {
fullProof.merkleTreeRoot,
fullProof.nullifier,
feedback,
fullProof.proof
fullProof.points
)

await expect(transaction)
Expand All @@ -64,7 +64,7 @@ describe("Feedback", () => {
fullProof.nullifier,
fullProof.message,
groupId,
fullProof.proof
fullProof.points
)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Feedback", () => {
fullProof.merkleTreeRoot,
fullProof.nullifier,
feedback,
fullProof.proof
fullProof.points
)

await expect(transaction)
Expand All @@ -64,7 +64,7 @@ describe("Feedback", () => {
fullProof.nullifier,
fullProof.message,
groupId,
fullProof.proof
fullProof.points
)
})
})
Expand Down
Loading

0 comments on commit fbc8efd

Please sign in to comment.