Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: zkey hash in marketplace config #81

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/Configuration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ struct ProofConfig {
uint256 period; // proofs requirements are calculated per period (in seconds)
uint256 timeout; // mark proofs as missing before the timeout (in seconds)
uint8 downtime; // ignore this much recent blocks for proof requirements
string zkeyHash; // hash of the zkey file which is linked to the verifier
}
5 changes: 4 additions & 1 deletion contracts/FuzzMarketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import "./TestVerifier.sol";
contract FuzzMarketplace is Marketplace {
constructor()
Marketplace(
MarketplaceConfig(CollateralConfig(10, 5, 3, 10), ProofConfig(10, 5, 64)),
MarketplaceConfig(
CollateralConfig(10, 5, 3, 10),
ProofConfig(10, 5, 64, "")
),
new TestToken(),
new TestVerifier()
)
Expand Down
5 changes: 4 additions & 1 deletion deploy/marketplace.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { loadZkeyHash } = require ("../verifier/verifier.js")

const MARKETPLACE_HARDCODED_ADDRESS = "0x59b670e9fA9D0A427751Af201D676719a970857b"

async function deployMarketplace({ deployments, getNamedAccounts }) {
async function deployMarketplace({ deployments, getNamedAccounts, network }) {
const token = await deployments.get("TestToken")
const verifier = await deployments.get("Groth16Verifier")
const configuration = {
Expand All @@ -14,6 +16,7 @@ async function deployMarketplace({ deployments, getNamedAccounts }) {
period: 10,
timeout: 5,
downtime: 64,
zkeyHash: loadZkeyHash(network.name),
},
}
const args = [configuration, token.address, verifier.address]
Expand Down
2 changes: 1 addition & 1 deletion test/Proofs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("Proofs", function () {
await deployments.fixture(["Groth16Verifier"])
const verifier = await deployments.get("Groth16Verifier")
proofs = await Proofs.deploy(
{ period, timeout, downtime },
{ period, timeout, downtime, zkeyHash: "" },
verifier.address
)
})
Expand Down
1 change: 1 addition & 0 deletions test/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const exampleConfiguration = () => ({
period: 10,
timeout: 5,
downtime: 64,
zkeyHash: "",
},
})

Expand Down
16 changes: 8 additions & 8 deletions verifier/networks/hardhat/example-proof/proof.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"pi_a": [
"5354152410986528740889949811485085083352383496724906496620004560773766258873",
"18134846030714314375408574013835366655850239581285468242834655581868166406486",
"7660723414354960115525441084999694570984078535773668898653309300593084455533",
"13530035710725348149248647938083875391713661082920395232005195032418705681044",
"1"
],
"pi_b": [
[
"4789242673778392422990537486305482696481357883414443488947138222420834201517",
"2027024107056245515978112401631176046626549081189495220144757031281248965782"
"2901049701023582640714756481602042737261909502555520071221132529600598809861",
"16912924802763251099243304625254406414459294932221399417825327530544648619341"
],
[
"14074051812573855135840075486089320372866984532507488654928193739831517782936",
"7485586556662798915982244873929621022563116002979775814431258294905458788251"
"1466763974310418266645354657059454821840794309805321553635263869263906930810",
"7919549687544999068783867201010060068898464272548283100322334851170181843674"
],
[
"1",
"0"
]
],
"pi_c": [
"13387824467635444633441399613298811843935004737405384070996599011859892267608",
"18364006371113837324322071862501578716151167725869146988611466294121991858941",
"16466626257875743363595172691363309940341494894360337991073652025213400816020",
"726868384379000975195472980386786614662718074766231997317916406216503344910",
"1"
],
"protocol": "groth16",
Expand Down
2 changes: 1 addition & 1 deletion verifier/networks/hardhat/example-proof/public.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
"7538754537",
"7613683355",
"16074246370508166450132968585287196391860062495017081813239200574579640171677",
"3"
]
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
],
"vk_delta_2": [
[
"9526465944650138768726332063321262597514193803543146241262920033512923206833",
"16947967852917776612242666765339055140004530219040719566241973405926209896589"
"7266368133833883232696069721567436218373292960862868097298822586114813920314",
"20179748680988515246787231619783022280905346903974148635767068251171792499335"
],
[
"19350668523204772149977938696677933779621485674406066708436704188235339847628",
"8391255886665123549932056926338579244742743577262957977406729945277596579696"
"11281139796322341653654563690864590481498751340552223660930514795611905053341",
"18865664978433701919673993490064453553613307046760943003771776295179590961997"
],
[
"1",
Expand Down
1 change: 1 addition & 0 deletions verifier/networks/hardhat/zkey_hash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"74fe889808fa3024e008ca603841e2afeda36044b70a06173e38ab82e632cea0"
11 changes: 9 additions & 2 deletions verifier/verifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const fs = require("fs")
const BASE_PATH = __dirname + "/networks"
const PROOF_FILE_NAME = "example-proof/proof.json"
const PUBLIC_INPUT_FILE_NAME = "example-proof/public.json"
const ZKEY_HASH_FILE_NAME = "zkey_hash.json"
const VERIFICATION_KEY_FILE_NAME =
"verification-key/proof_main_verification_key.json"
"proof_main_verification_key.json"

function G1ToStruct(point) {
return {
Expand Down Expand Up @@ -36,6 +37,12 @@ function loadPublicInput(name) {
return input
}

function loadZkeyHash(name) {
const path = `${BASE_PATH}/${name}/${ZKEY_HASH_FILE_NAME}`
const input = JSON.parse(fs.readFileSync(path))
return input
}

function loadVerificationKey(name) {
const path = `${BASE_PATH}/${name}/${VERIFICATION_KEY_FILE_NAME}`
const key = JSON.parse(fs.readFileSync(path))
Expand All @@ -48,4 +55,4 @@ function loadVerificationKey(name) {
}
}

module.exports = { loadProof, loadPublicInput, loadVerificationKey }
module.exports = { loadProof, loadPublicInput, loadVerificationKey, loadZkeyHash }