feat: zkey hash in marketplace config (#81)

This commit is contained in:
Adam Uhlíř 2024-01-30 06:36:27 +01:00 committed by GitHub
parent a186cb4045
commit 331bc56e8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 34 additions and 18 deletions

View File

@ -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
}

View File

@ -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()
)

View File

@ -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 = {
@ -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]

View File

@ -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
)
})

View File

@ -14,6 +14,7 @@ const exampleConfiguration = () => ({
period: 10,
timeout: 5,
downtime: 64,
zkeyHash: "",
},
})

View File

@ -1,17 +1,17 @@
{
"pi_a": [
"5354152410986528740889949811485085083352383496724906496620004560773766258873",
"18134846030714314375408574013835366655850239581285468242834655581868166406486",
"7660723414354960115525441084999694570984078535773668898653309300593084455533",
"13530035710725348149248647938083875391713661082920395232005195032418705681044",
"1"
],
"pi_b": [
[
"4789242673778392422990537486305482696481357883414443488947138222420834201517",
"2027024107056245515978112401631176046626549081189495220144757031281248965782"
"2901049701023582640714756481602042737261909502555520071221132529600598809861",
"16912924802763251099243304625254406414459294932221399417825327530544648619341"
],
[
"14074051812573855135840075486089320372866984532507488654928193739831517782936",
"7485586556662798915982244873929621022563116002979775814431258294905458788251"
"1466763974310418266645354657059454821840794309805321553635263869263906930810",
"7919549687544999068783867201010060068898464272548283100322334851170181843674"
],
[
"1",
@ -19,8 +19,8 @@
]
],
"pi_c": [
"13387824467635444633441399613298811843935004737405384070996599011859892267608",
"18364006371113837324322071862501578716151167725869146988611466294121991858941",
"16466626257875743363595172691363309940341494894360337991073652025213400816020",
"726868384379000975195472980386786614662718074766231997317916406216503344910",
"1"
],
"protocol": "groth16",

View File

@ -1,5 +1,5 @@
[
"7538754537",
"7613683355",
"16074246370508166450132968585287196391860062495017081813239200574579640171677",
"3"
]

View File

@ -37,12 +37,12 @@
],
"vk_delta_2": [
[
"9526465944650138768726332063321262597514193803543146241262920033512923206833",
"16947967852917776612242666765339055140004530219040719566241973405926209896589"
"7266368133833883232696069721567436218373292960862868097298822586114813920314",
"20179748680988515246787231619783022280905346903974148635767068251171792499335"
],
[
"19350668523204772149977938696677933779621485674406066708436704188235339847628",
"8391255886665123549932056926338579244742743577262957977406729945277596579696"
"11281139796322341653654563690864590481498751340552223660930514795611905053341",
"18865664978433701919673993490064453553613307046760943003771776295179590961997"
],
[
"1",

View File

@ -0,0 +1 @@
"74fe889808fa3024e008ca603841e2afeda36044b70a06173e38ab82e632cea0"

View File

@ -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 {
@ -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))
@ -48,4 +55,4 @@ function loadVerificationKey(name) {
}
}
module.exports = { loadProof, loadPublicInput, loadVerificationKey }
module.exports = { loadProof, loadPublicInput, loadVerificationKey, loadZkeyHash }