logos-storage-contracts-eth/test/Bn254Verifier.test.js
Eric Mastro c0be4e9b1d
WIP: reorg curves, use witnet as base
Now that curve ops are transactions, need to change up tests so that we can verify the result somehow? https://docs.ethers.io/v5/api/contract/contract/#Contract--write
2022-06-08 15:16:08 +10:00

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(
"elliptic curve multiplication failed"
)
})
})