Browse Source

Add extra point in lagrange to avoid constant polinomials

master
Jordi Baylina 6 years ago
parent
commit
7a9bdf5961
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
4 changed files with 5 additions and 9 deletions
  1. +2
    -2
      src/setup.js
  2. +1
    -5
      test/zksnark.js
  3. +1
    -1
      vk_proof.json
  4. +1
    -1
      vk_verifier.json

+ 2
- 2
src/setup.js

@ -70,13 +70,13 @@ function calculatePolinomials(setup, circuit) {
cPoints[s].push([[bigInt(c), F.one], [circuit.c(c, s), F.one]]);
}
// Add an extra point to avoid constant polinolials.
/* setup.toxic.aExtra[s] = F.random();
setup.toxic.aExtra[s] = F.random();
setup.toxic.bExtra[s] = F.random();
setup.toxic.cExtra[s] = F.random();
aPoints[s].push([[bigInt(circuit.nConstrains), F.one], [setup.toxic.aExtra[s], F.one]]);
bPoints[s].push([[bigInt(circuit.nConstrains), F.one], [setup.toxic.aExtra[s], F.one]]);
cPoints[s].push([[bigInt(circuit.nConstrains), F.one], [setup.toxic.aExtra[s], F.one]]);
*/ </span><span class="err"> pan> }
}
// Calculate the polinomials using Lagrange
setup.vk_proof.polsA = [];

+ 1
- 5
test/zksnark.js

@ -62,13 +62,9 @@ function unstringifyBigInts(o) {
describe("zkSnark", () => {
it("Load a circuit, create trusted setup, create a proof and validate", () => {
const cirDef = JSON.parse(fs.readFileSync(path.join(__dirname, "circuit", "sum_old.json"), "utf8"));
const cirDef = JSON.parse(fs.readFileSync(path.join(__dirname, "circuit", "sum.json"), "utf8"));
const cir = new Circuit(cirDef);
console.log("Signals: " + cir.nSignals);
console.log("Vars: " + cir.nVars);
console.log("Constants: " + cir.nConstants);
const setup = zkSnark.setup(cir);
const strSetup = stringifyBigInts(setup);
fs.writeFileSync("vk_proof.json", JSON.stringify(strSetup.vk_proof), "utf-8");

+ 1
- 1
vk_proof.json
File diff suppressed because it is too large
View File


+ 1
- 1
vk_verifier.json

@ -1 +1 @@
{"nPublic":2,"A":[["0","1","0"],["0","1","0"],["0","1","0"]],"vk_a":[["7089990502144118832604367521011815819798606716933228956649110482164464380406","11230368732527352934600748828578966453798139638406648889650954564514158968703"],["2552025287468333777208188228671587362279970708925048598762654161010066177043","15817150506762213830286503668291435731391320924329741514835476096095673797541"],["1","0"]],"vk_b":["21226082957049381990294170600222709388915844017670592613996115036848934411084","6006027414836389636439941146361896036828945752850102505912600116069920998905","1"],"vk_c":[["14972475653539484594981526569218338016113092790075151393066856871644596682724","21082271776918104650812338650952413460358778951692637967538121533518900717477"],["9488935497761382226730503363657417022919431431195898152774653504290411140945","19381581614863000065474721359406816581030290577744306196107899638975834631453"],["1","0"]],"vk_gb_1":["21252927779317539356866989571443021111053362742199247507918719071083375839517","10363106511526332770968391923850585843602882105799869583139073142840826136733","1"],"vk_gb_2":[["4008279642693334257982765700260663237694948550659008283313366773842380503881","8753806373766515819666987287783146863922344545260667289971101962956210093327"],["5807885013795520098816830751231276772859952798588983742628691967101071302818","6978771515240022856338630590059538314801825386905681885426584494404793679829"],["1","0"]],"vk_g":[["4320480846845722370509620085106073102683489399848883412499707153377041321853","21539907783935770792755522803992030540887731620905279286817443960442024347124"],["1151638670443091902847376995820628224336466611917726211841718214221717869223","21656897510530916728876429664556536866823248506277537270768352818364789952939"],["1","0"]],"vk_z":[["14036484800577492864176055863563743801312918031455705713947899654164747095274","17621798242161700147652033360082706311851117228822901176511817790342197240076"],["16373804800800879502996680064240926365601097587279049944810167207060925171284","11833921311104078902370088937110388846651781339933440468666548707337992518688"],["1","0"]]}
{"nPublic":2,"A":[["7785852424866942827567248153177252939222290906182691438082699528717261848112","14498487571140582006229521774123197624792208304995460366041293455685310260821","1"],["10089186025810067574406329116352287427202151507453454942488303185615585009763","17480610045118135048097764965111383435546896631536763842128581740796692699545","1"],["7958582426685674530371319836968288880305942218180473830509366672077811746037","10638141525118745391331643953261526086411343214394172786686412004744903280719","1"]],"vk_a":[["12566476700762111387137638462830143693098966342488031797140199812463702270691","10761117940182937104105395766999898001336380831618788449416100226892191721352"],["19356030820036623417777165953349381769963830588263613016091378865373303462959","18978533904220143511207404775924520995666097373381834434667481778541007087709"],["1","0"]],"vk_b":["17043210079194738757796936679118088906904204909725217298217365257820271414495","6707474775531150240403871468575244487808879053949462404945041228167524099845","1"],"vk_c":[["9865170618584112823441502162349285335860423740128360526669357554747472154699","20632604718736815280919467681151136499210670980285160959222493223050513546737"],["14082216868713174642563399832185872527728254502321978474744586860936084370133","5685222283821451402334606207202637975255815512242614931036232914597987353342"],["1","0"]],"vk_gb_1":["9836395603840470046963943712532881651486509931256407713019946950913137629778","14094948388393434838547760783099810192358837696587972297173500041190367621741","1"],"vk_gb_2":[["10587661408747044872089155440730374654971725374954943430414222839166754618438","2651255471732063779449759857880587162577951271595365104927101365422800353575"],["7699696976839240235764497561272408204654578388769442088875499039868922178043","12736174663397154234466813918688257074075249792170264326428492908710414485777"],["1","0"]],"vk_g":[["16743811095305513197394434499991440630928809821202268624747413762738629515203","13558714849344702204918921046456627261658997126791422789906958103126834063528"],["5893688669347543877075775593021751388729139028769910418467883741922299058562","3517258497343919686729984857929694939897364088993819600570135956125448214649"],["1","0"]],"vk_z":[["14315684838123152822561898371476735839014217469791062349956797159719883767","2872518261424628556632141313617513762966654266713260679885493065940055845946"],["16343384596178098264749066292007666749105974458588741482468417161840088549271","4270162096643902647870128224797797634127338751539821383607674884042111088595"],["1","0"]]}

Loading…
Cancel
Save