Skip to content

Commit

Permalink
Allow proof lock to be updated
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Zhang <[email protected]>
  • Loading branch information
jimthematrix committed Sep 26, 2024
1 parent 5ae387b commit 07379c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion solidity/contracts/lib/zeto_common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ abstract contract ZetoCommon is OwnableUpgradeable {
address delegate
) public {
bytes32 proofHash = Commonlib.getProofHash(proof);
require(lockedProofs[proofHash] == address(0), "Proof already locked");
require(
lockedProofs[proofHash] == address(0) ||
lockedProofs[proofHash] == msg.sender,
"Proof already locked by another party"
);
if (delegate != address(0)) {
lockedProofs[proofHash] = delegate;
} else {
Expand Down
11 changes: 11 additions & 0 deletions solidity/test/zkDvP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ describe("DvP flows between fungible and non-fungible tokens based on Zeto with
await expect(zkDvP.connect(Bob.signer).acceptTrade(tradeId, [0, 0], [0, 0], mockProofHash, 0, 0, mockProofHash)).rejectedWith("Payment inputs must be provided to accept the trade");
await expect(zkDvP.connect(Bob.signer).acceptTrade(tradeId, [utxo3.hash, utxo4.hash], [0, 0], mockProofHash, 0, 0, mockProofHash)).rejectedWith("Payment outputs must be provided to accept the trade");
});

it("test proof locking", async function () {
const circuit1 = await loadCircuit('anon');
const { provingKeyFile: provingKey1 } = loadProvingKeys('anon');
const utxo1 = newUTXO(100, Alice);
const proof = await zetoAnonTests.prepareProof(circuit1, provingKey1, Alice, [utxo1, ZERO_UTXO], [utxo1, ZERO_UTXO], [Alice, {}]);

await expect(zkPayment.connect(Alice.signer).lockProof(proof.encodedProof, "0x0000000000000000000000000000000000000000")).fulfilled;
await expect(zkPayment.connect(Bob.signer).lockProof(proof.encodedProof, await Bob.signer.getAddress())).rejectedWith("Proof already locked by another party");
await expect(zkPayment.connect(Alice.signer).lockProof(proof.encodedProof, await Bob.signer.getAddress())).fulfilled;
});
});

}).timeout(600000);

0 comments on commit 07379c3

Please sign in to comment.