mirror of
https://github.com/codex-storage/codex-contracts-eth.git
synced 2025-02-10 10:26:32 +00:00
Test verifier accepts any proof, except all 0 values
This commit is contained in:
parent
331bc56e8f
commit
ec803adb3d
@ -4,20 +4,19 @@ pragma solidity 0.8.23;
|
|||||||
import "./Groth16.sol";
|
import "./Groth16.sol";
|
||||||
|
|
||||||
contract TestVerifier is IGroth16Verifier {
|
contract TestVerifier is IGroth16Verifier {
|
||||||
bool private _proofsAreValid;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
_proofsAreValid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setProofsAreValid(bool proofsAreValid) public {
|
|
||||||
_proofsAreValid = proofsAreValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
function verify(
|
function verify(
|
||||||
Groth16Proof calldata,
|
Groth16Proof calldata proof,
|
||||||
uint[] calldata
|
uint[] calldata
|
||||||
) external view returns (bool) {
|
) external pure returns (bool) {
|
||||||
return _proofsAreValid;
|
// accepts any proof, except the proof with all zero values
|
||||||
|
return
|
||||||
|
!(proof.a.x == 0 &&
|
||||||
|
proof.a.y == 0 &&
|
||||||
|
proof.b.x[0] == 0 &&
|
||||||
|
proof.b.x[1] == 0 &&
|
||||||
|
proof.b.y[0] == 0 &&
|
||||||
|
proof.b.y[1] == 0 &&
|
||||||
|
proof.c.x == 0 &&
|
||||||
|
proof.c.y == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ const {
|
|||||||
exampleConfiguration,
|
exampleConfiguration,
|
||||||
exampleRequest,
|
exampleRequest,
|
||||||
exampleProof,
|
exampleProof,
|
||||||
|
invalidProof,
|
||||||
} = require("./examples")
|
} = require("./examples")
|
||||||
const { periodic, hours } = require("./time")
|
const { periodic, hours } = require("./time")
|
||||||
const { requestId, slotId, askToArray } = require("./ids")
|
const { requestId, slotId, askToArray } = require("./ids")
|
||||||
@ -219,9 +220,8 @@ describe("Marketplace", function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("is rejected when proof is incorrect", async function () {
|
it("is rejected when proof is incorrect", async function () {
|
||||||
await verifier.setProofsAreValid(false)
|
|
||||||
await expect(
|
await expect(
|
||||||
marketplace.fillSlot(slot.request, slot.index, proof)
|
marketplace.fillSlot(slot.request, slot.index, invalidProof())
|
||||||
).to.be.revertedWith("Invalid proof")
|
).to.be.revertedWith("Invalid proof")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -46,4 +46,15 @@ const exampleProof = () => ({
|
|||||||
c: { x: 7, y: 8 },
|
c: { x: 7, y: 8 },
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = { exampleConfiguration, exampleRequest, exampleProof }
|
const invalidProof = () => ({
|
||||||
|
a: { x: 0, y: 0 },
|
||||||
|
b: { x: [0, 0], y: [0, 0] },
|
||||||
|
c: { x: 0, y: 0 },
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
exampleConfiguration,
|
||||||
|
exampleRequest,
|
||||||
|
exampleProof,
|
||||||
|
invalidProof,
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user