Skip to content

Commit

Permalink
added vyper plonk verifier template
Browse files Browse the repository at this point in the history
  • Loading branch information
mllwchrry committed Oct 2, 2024
1 parent e8e6a3e commit 2615ef2
Show file tree
Hide file tree
Showing 11 changed files with 797 additions and 794 deletions.
793 changes: 0 additions & 793 deletions package-lock.json

Large diffs are not rendered by default.

646 changes: 646 additions & 0 deletions src/core/templates/verifier_plonk.vy.ejs

Large diffs are not rendered by default.

38 changes: 37 additions & 1 deletion test/CircuitZKit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ describe("CircuitZKit", () => {
expect(await verifier.verifyProof(...data)).to.be.true;
});

it("should correctly create verifier and verify 'plonk' proof", async function () {
it("should correctly create Solidity verifier and verify 'plonk' proof", async function () {
const circuitName = "Multiplier";
const verifierDirPath = getVerifiersDirFullPath();
const artifactsDirFullPath = getArtifactsFullPath(`${circuitName}.circom`);
Expand Down Expand Up @@ -257,6 +257,42 @@ describe("CircuitZKit", () => {
expect(await verifier.verifyProof(...data)).to.be.true;
});

it("should correctly create Vyper verifier and verify 'plonk' proof", async function () {
const circuitName = "MultiDimensionalArray";
const verifierDirPath = getVerifiersDirFullPath();
const artifactsDirFullPath = getArtifactsFullPath(`${circuitName}.circom`);

const mdArrayCircuit = getCircuitZKit<"plonk">(circuitName, "plonk", {
circuitName,
circuitArtifactsPath: artifactsDirFullPath,
verifierDirPath,
});

const expectedVerifierFilePath = path.join(verifierDirPath, `${mdArrayCircuit.getVerifierName()}.vy`);

await mdArrayCircuit.createVerifier("vy");
expect(fs.existsSync(expectedVerifierFilePath)).to.be.true;

await this.hre.run("compile", { quiet: true });

const a = 2;
const b = [
[3, 1],
[44, 2],
];

const proof: any = await mdArrayCircuit.generateProof({ a, b });

expect(await mdArrayCircuit.verifyProof(proof)).to.be.true;

let data = await mdArrayCircuit.generateCalldata(proof);

const MdArrayVerifierFactory = await this.hre.ethers.getContractFactory("MultiDimensionalArrayPlonkVerifier");
const verifier = await MdArrayVerifierFactory.deploy();

expect(await verifier.verifyProof(...data)).to.be.true;
});

it("should correctly create verifier several times", async () => {
const circuitName = "Multiplier";
const verifierDirPath = getVerifiersDirFullPath();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"protocol":"groth16","curve":"bn128","nPublic":10,"vk_alpha_1":["20491192805390485299153009773594534940189261866228447918068658471970481763042","9383485363053290200918347156157836566562967994039712273449902621266178545958","1"],"vk_beta_2":[["6375614351688725206403948262868962793625744043794305715222011528459656738731","4252822878758300859123897981450591353533073413197771768651442665752259397132"],["10505242626370262277552901082094356697409835680220590971873171140371331206856","21847035105528745403288232691147584728191162732299865338377159692350059136679"],["1","0"]],"vk_gamma_2":[["10857046999023057135944570762232829481370756359578518086990519993285655852781","11559732032986387107991004021392285783925812861821192530917403151452391805634"],["8495653923123431417604973247489272438418190587263600148770280649306958101930","4082367875863433681332203403145435568316851327593401208105741076214120093531"],["1","0"]],"vk_delta_2":[["11121757548064786277347723654771777697589351852136688710265908558867619706034","9511594120864330497760845197961554462019421854459034930600159412099448314441"],["11128786009117993081930366203489510400564801483205509889654407453019543621040","11890586469707710102408840231956795235484070722927440244326941071149147642216"],["1","0"]],"vk_alphabeta_12":[[["2029413683389138792403550203267699914886160938906632433982220835551125967885","21072700047562757817161031222997517981543347628379360635925549008442030252106"],["5940354580057074848093997050200682056184807770593307860589430076672439820312","12156638873931618554171829126792193045421052652279363021382169897324752428276"],["7898200236362823042373859371574133993780991612861777490112507062703164551277","7074218545237549455313236346927434013100842096812539264420499035217050630853"]],[["7077479683546002997211712695946002074877511277312570035766170199895071832130","10093483419865920389913245021038182291233451549023025229112148274109565435465"],["4595479056700221319381530156280926371456704509942304414423590385166031118820","19831328484489333784475432780421641293929726139240675179672856274388269393268"],["11934129596455521040620786944827826205713621633706285934057045369193958244500","8037395052364110730298837004334506829870972346962140206007064471173334027475"]]],"IC":[["3495694661568299179878948819174043851099678885336797490532661625634509456620","16449691720535956946494884801163388207063380307723678096092208850886491784850","1"],["2054279236838943706274953313756236537292322036282609347844303283687859336981","9310409617016868204445399592192768984461464076263793259131162336791588460855","1"],["4549101963883882136918061717506048747536543905969847743955187512947029251427","286982476162680491638647191378244700891252328354935273227013602617490386723","1"],["11884708174745769330192779892650439092194966066571302312721385264001937381049","13268131990047414176823694405854210162868219587848624459696126135172990017117","1"],["9799474276727028348664964041671679914724919422982579865092122769382950313536","6713034376041512319939194002721319007645465116926144109484961044854657959476","1"],["14022296220194218890981220204229983993676986201618170329944669925145440704166","2519510297529842692804647714336136314718121866392421315400801702201549332604","1"],["11474327268813938951012760319915851216855228323616198999638918058098493270120","16500656588235391685173826059205066302968692203113601429633113299933455194629","1"],["20796238970784755517182802061293333668486710089460310703934446287285882219146","3213077213885759377398277506040700138865811142585808906555900192062143733907","1"],["4755241111656492396903273326956608795143382767922486875641623966708572717243","16619885589196258576144193149671578663463975844477089736502404890231654038593","1"],["14950193769065094782935245708676799536470457473265243091124885117312549616769","6465459252878178455071904296538722022857571708009548619696960085030101615929","1"],["385979438052586810495960114303961400723993708222649653587148950133873626122","13447321594156279890979317717555593354311661716332933890908752718991044747964","1"]]}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"protocol": "plonk",
"curve": "bn128",
"nPublic": 10,
"power": 5,
"k1": "2",
"k2": "3",
"Qm": [
"20725296897021676741273642056169240329285346916285158361938444652581257033543",
"19707517720670499485357295484830119779349041426479603650432203457136506504553",
"1"
],
"Ql": [
"17359212988294702391946214274081597524316206017774228682133243429316382466169",
"13186074013007479625987897051305103109875388027117735083702144928328328417354",
"1"
],
"Qr": [
"14758822207824189241801199980321211283852275118707770109155494450459528308433",
"3111427114158633020352054765874786995654636141967641700746131063752278357531",
"1"
],
"Qo": [
"6244574162614808265956747865576107056431639803026857745017764366785514855788",
"3702796362167115123753264446046062519683988921847065794467224235285920160499",
"1"
],
"Qc": [
"19044597030438802983566910140227291914987665533437629098515891922685580896837",
"4657908630292315873601421240069348459791191118362492110690688921349850751286",
"1"
],
"S1": [
"15429054937789019171757319325502284862527279286683877739760989574604467061479",
"7821930593052013494045041470471816095239727048579657070946420897376673917026",
"1"
],
"S2": [
"3173429328132607418336872096074210942038805266431548245139519027688183520874",
"15855441316377869984246871206599918935607091929588958108942938040758330929807",
"1"
],
"S3": [
"9040900506899513085679484076599580398059396139904684129570618813481205004777",
"16820393608784268482740650194967033277242455801099197806602971357487892770048",
"1"
],
"X_2": [
[
"21831381940315734285607113342023901060522397560371972897001948545212302161822",
"17231025384763736816414546592865244497437017442647097510447326538965263639101"
],
[
"2388026358213174446665280700919698872609886601280537296205114254867301080648",
"11507326595632554467052522095592665270651932854513688777769618397986436103170"
],
[
"1",
"0"
]
],
"w": "4419234939496763621076330863786513495701855246241724391626358375488475697872"
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
1,1,0,main.out1
2,2,0,main.out2[0][0]
3,3,0,main.out2[0][1]
4,4,0,main.out2[1][0]
5,5,0,main.out2[1][1]
6,6,0,main.a
7,7,0,main.b[0][0]
8,8,0,main.b[0][1]
9,9,0,main.b[1][0]
10,10,0,main.b[1][1]
11,11,0,main.m
12,-1,0,main.isEqual
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"_format": "hh-zkit-artifacts-1",
"circuitTemplateName": "MultiDimensionalArray",
"circuitFileName": "MultiDimensionalArray",
"circuitSourceName": "circuits/MultiDimensionalArray.circom",
"baseCircuitInfo": {
"constraintsNumber": 6,
"signals": [
{
"name": "a",
"dimension": [],
"type": "Input",
"visibility": "Public"
},
{
"name": "b",
"dimension": ["2", "2"],
"type": "Input",
"visibility": "Public"
},
{
"name": "out1",
"dimension": [],
"type": "Output",
"visibility": "Public"
},
{
"name": "out2",
"dimension": [
"2",
"2"
],
"type": "Output",
"visibility": "Public"
}
]
}
}
Binary file not shown.

0 comments on commit 2615ef2

Please sign in to comment.