mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-14 19:23:13 +00:00
Needs valid values to test points that exist on the curve as well as a valid proof. Waiting on https://github.com/status-im/nim-codex/pull/101 to get valid values. TODO: Convert Bn254.sol contract to a generic witnet EllipticCurve.sol contract and fill in values as needed for the Bn254 curve.
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
const { expect } = require("chai")
|
|
const { ethers } = require("hardhat")
|
|
const {
|
|
snapshot,
|
|
revert,
|
|
ensureMinimumBlockHeight,
|
|
advanceTime,
|
|
} = require("./evm")
|
|
|
|
describe("Bn254Verifier", function () {
|
|
let bn254
|
|
|
|
beforeEach(async function () {
|
|
await snapshot()
|
|
await ensureMinimumBlockHeight(256)
|
|
const Bn254Verifier = await ethers.getContractFactory("TestBn254Verifier")
|
|
verifier = await Bn254Verifier.deploy()
|
|
})
|
|
|
|
afterEach(async function () {
|
|
await revert()
|
|
})
|
|
|
|
it("fails when first point is not on Bn254 curve", async function () {
|
|
let proof = {
|
|
q: [
|
|
{ i: -1, v: 1 },
|
|
{ i: -2, v: 2 },
|
|
{ i: -3, v: 3 },
|
|
],
|
|
mus: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
|
|
sigma: { X: 1, Y: 2 },
|
|
u: [
|
|
{ X: 1, Y: 2 },
|
|
{ X: 2, Y: 2 },
|
|
{ X: 3, Y: 3 },
|
|
],
|
|
name: ethers.utils.toUtf8Bytes("test"),
|
|
publicKey: {
|
|
X: [1, 2],
|
|
Y: [1, 2],
|
|
},
|
|
}
|
|
await expect(verifier.verifyProof(proof)).to.be.revertedWith(
|
|
"must be on Bn254 curve"
|
|
)
|
|
})
|
|
})
|