Poseidon BN128 (#20)

* initial commit of poseidon bn128

* got challenger working

* deserialize is working

* cleaned up deserialization function a bit

* fixed challenger

* add in the hack to the challenges

* fixed some bugs in poseidon_bn128

* fri verification is working

* some changes for benchmarking

* added decode_block plonky2 data

* initial commit for poseidon_mds_gate

* updated gate test cases

* working poseidon mds gate

* full verifier test case working
This commit is contained in:
Kevin Jue
2023-06-06 17:36:51 -07:00
committed by GitHub
parent 302b5f5bf1
commit a516925ad8
49 changed files with 16962 additions and 150846 deletions

View File

@@ -11,15 +11,16 @@ import (
)
type ChallengerChip struct {
api frontend.API `gnark:"-"`
field field.FieldAPI `gnark:"-"`
poseidonChip *poseidon.PoseidonChip
spongeState [poseidon.SPONGE_WIDTH]field.F
inputBuffer []field.F
outputBuffer []field.F
api frontend.API `gnark:"-"`
field field.FieldAPI `gnark:"-"`
poseidonChip *poseidon.PoseidonChip
poseidonBN128Chip *poseidon.PoseidonBN128Chip
spongeState [poseidon.SPONGE_WIDTH]field.F
inputBuffer []field.F
outputBuffer []field.F
}
func NewChallengerChip(api frontend.API, fieldAPI field.FieldAPI, poseidonChip *poseidon.PoseidonChip) *ChallengerChip {
func NewChallengerChip(api frontend.API, fieldAPI field.FieldAPI, poseidonChip *poseidon.PoseidonChip, poseidonBN128Chip *poseidon.PoseidonBN128Chip) *ChallengerChip {
var spongeState [poseidon.SPONGE_WIDTH]field.F
var inputBuffer []field.F
var outputBuffer []field.F
@@ -29,12 +30,13 @@ func NewChallengerChip(api frontend.API, fieldAPI field.FieldAPI, poseidonChip *
}
return &ChallengerChip{
api: api,
field: fieldAPI,
poseidonChip: poseidonChip,
spongeState: spongeState,
inputBuffer: inputBuffer,
outputBuffer: outputBuffer,
api: api,
field: fieldAPI,
poseidonChip: poseidonChip,
poseidonBN128Chip: poseidonBN128Chip,
spongeState: spongeState,
inputBuffer: inputBuffer,
outputBuffer: outputBuffer,
}
}
@@ -52,13 +54,19 @@ func (c *ChallengerChip) ObserveElements(elements []field.F) {
}
}
func (c *ChallengerChip) ObserveHash(hash poseidon.Hash) {
c.ObserveElements(hash[:])
func (c *ChallengerChip) ObserveHash(hash poseidon.PoseidonHashOut) {
elements := c.poseidonChip.ToVec(hash)
c.ObserveElements(elements)
}
func (c *ChallengerChip) ObserveCap(cap []poseidon.Hash) {
func (c *ChallengerChip) ObserveBN128Hash(hash poseidon.PoseidonBN128HashOut) {
elements := c.poseidonBN128Chip.ToVec(hash)
c.ObserveElements(elements)
}
func (c *ChallengerChip) ObserveCap(cap []poseidon.PoseidonBN128HashOut) {
for i := 0; i < len(cap); i++ {
c.ObserveHash(cap[i])
c.ObserveBN128Hash(cap[i])
}
}
@@ -102,7 +110,7 @@ func (c *ChallengerChip) GetExtensionChallenge() field.QuadraticExtension {
return field.QuadraticExtension{values[0], values[1]}
}
func (c *ChallengerChip) GetHash() poseidon.Hash {
func (c *ChallengerChip) GetHash() poseidon.PoseidonHashOut {
return [4]field.F{c.GetChallenge(), c.GetChallenge(), c.GetChallenge(), c.GetChallenge()}
}
@@ -140,9 +148,7 @@ func (c *ChallengerChip) duplexing() {
panic("something went wrong")
}
for i := 0; i < len(c.inputBuffer); i++ {
c.spongeState[i] = c.inputBuffer[i]
}
copy(c.spongeState[:], c.inputBuffer)
c.inputBuffer = clearBuffer(c.inputBuffer)
c.spongeState = c.poseidonChip.Poseidon(c.spongeState)
clearBuffer(c.outputBuffer)

View File

@@ -1,21 +1,21 @@
package plonk
import (
"math/big"
"testing"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/test"
"github.com/succinctlabs/gnark-plonky2-verifier/field"
"github.com/succinctlabs/gnark-plonky2-verifier/poseidon"
"github.com/succinctlabs/gnark-plonky2-verifier/utils"
)
type TestChallengerCircuit struct {
PublicInputs [3]frontend.Variable
CircuitDigest [4]frontend.Variable
WiresCap [16][4]frontend.Variable
PlonkZsPartialProductsCap [16][4]frontend.Variable
QuotientPolysCap [16][4]frontend.Variable
PublicInputs []field.F
CircuitDigest poseidon.PoseidonBN128HashOut
WiresCap [16]poseidon.PoseidonBN128HashOut
PlonkZsPartialProductsCap [16]poseidon.PoseidonBN128HashOut
QuotientPolysCap [16]poseidon.PoseidonBN128HashOut
}
func (circuit *TestChallengerCircuit) Define(api frontend.API) error {
@@ -23,53 +23,23 @@ func (circuit *TestChallengerCircuit) Define(api frontend.API) error {
degreeBits := 3
qeAPI := field.NewQuadraticExtensionAPI(api, fieldAPI, uint64(degreeBits))
poseidonChip := poseidon.NewPoseidonChip(api, fieldAPI, qeAPI)
challengerChip := NewChallengerChip(api, fieldAPI, poseidonChip)
poseidonBN128Chip := poseidon.NewPoseidonBN128Chip(api, fieldAPI)
challengerChip := NewChallengerChip(api, fieldAPI, poseidonChip, poseidonBN128Chip)
var circuitDigest [4]field.F
for i := 0; i < len(circuitDigest); i++ {
circuitDigest[i] = fieldAPI.FromBits(api.ToBinary(circuit.CircuitDigest[i], 64)...)
}
var publicInputs [3]field.F
for i := 0; i < len(publicInputs); i++ {
publicInputs[i] = fieldAPI.FromBits(api.ToBinary(circuit.PublicInputs[i], 64)...)
}
var wiresCap [16][4]field.F
for i := 0; i < len(wiresCap); i++ {
for j := 0; j < len(wiresCap[0]); j++ {
wiresCap[i][j] = fieldAPI.FromBits(api.ToBinary(circuit.WiresCap[i][j], 64)...)
}
}
var plonkZsPartialProductsCap [16][4]field.F
for i := 0; i < len(plonkZsPartialProductsCap); i++ {
for j := 0; j < len(plonkZsPartialProductsCap[0]); j++ {
plonkZsPartialProductsCap[i][j] = fieldAPI.FromBits(api.ToBinary(circuit.PlonkZsPartialProductsCap[i][j], 64)...)
}
}
var quotientPolysCap [16][4]field.F
for i := 0; i < len(quotientPolysCap); i++ {
for j := 0; j < len(quotientPolysCap[0]); j++ {
quotientPolysCap[i][j] = fieldAPI.FromBits(api.ToBinary(circuit.QuotientPolysCap[i][j], 64)...)
}
}
publicInputHash := poseidonChip.HashNoPad(publicInputs[:])
challengerChip.ObserveHash(circuitDigest)
challengerChip.ObserveBN128Hash(circuit.CircuitDigest)
publicInputHash := poseidonChip.HashNoPad(circuit.PublicInputs[:])
challengerChip.ObserveHash(publicInputHash)
challengerChip.ObserveCap(wiresCap[:])
challengerChip.ObserveCap(circuit.WiresCap[:])
numChallenges := uint64(2)
plonkBetas := challengerChip.GetNChallenges(numChallenges)
plonkGammas := challengerChip.GetNChallenges(numChallenges)
expectedPublicInputHash := [4]field.F{
field.NewFieldConstFromString("8416658900775745054"),
field.NewFieldConstFromString("12574228347150446423"),
field.NewFieldConstFromString("9629056739760131473"),
field.NewFieldConstFromString("3119289788404190010"),
field.NewFieldConstFromString("0"),
field.NewFieldConstFromString("0"),
field.NewFieldConstFromString("0"),
field.NewFieldConstFromString("0"),
}
for i := 0; i < 4; i++ {
@@ -77,13 +47,13 @@ func (circuit *TestChallengerCircuit) Define(api frontend.API) error {
}
expectedPlonkBetas := [2]field.F{
field.NewFieldConstFromString("4678728155650926271"),
field.NewFieldConstFromString("13611962404289024887"),
field.NewFieldConstFromString("17615363392879944733"),
field.NewFieldConstFromString("9422446877322953047"),
}
expectedPlonkGammas := [2]field.F{
field.NewFieldConstFromString("13237663823305715949"),
field.NewFieldConstFromString("15389314098328235145"),
field.NewFieldConstFromString("15174493176564484303"),
field.NewFieldConstFromString("6175150444166239851"),
}
for i := 0; i < 2; i++ {
@@ -91,24 +61,24 @@ func (circuit *TestChallengerCircuit) Define(api frontend.API) error {
fieldAPI.AssertIsEqual(plonkGammas[i], expectedPlonkGammas[i])
}
challengerChip.ObserveCap(plonkZsPartialProductsCap[:])
challengerChip.ObserveCap(circuit.PlonkZsPartialProductsCap[:])
plonkAlphas := challengerChip.GetNChallenges(numChallenges)
expectedPlonkAlphas := [2]field.F{
field.NewFieldConstFromString("14505919539124304197"),
field.NewFieldConstFromString("1695455639263736117"),
field.NewFieldConstFromString("9276470834414745550"),
field.NewFieldConstFromString("5302812342351431915"),
}
for i := 0; i < 2; i++ {
fieldAPI.AssertIsEqual(plonkAlphas[i], expectedPlonkAlphas[i])
}
challengerChip.ObserveCap(quotientPolysCap[:])
challengerChip.ObserveCap(circuit.QuotientPolysCap[:])
plonkZeta := challengerChip.GetExtensionChallenge()
expectedPlonkZeta := field.QuadraticExtension{
field.NewFieldConstFromString("14887793628029982930"),
field.NewFieldConstFromString("1136137158284059037"),
field.NewFieldConstFromString("3892795992421241388"),
field.NewFieldConstFromString("15786647757418200302"),
}
for i := 0; i < 2; i++ {
@@ -118,15 +88,25 @@ func (circuit *TestChallengerCircuit) Define(api frontend.API) error {
return nil
}
func StringToBN128Hash(hashStr string) poseidon.PoseidonBN128HashOut {
hashBigInt, ok := new(big.Int).SetString(hashStr, 10)
if !(ok) {
panic("Invalid hash: " + hashStr)
}
hashVar := frontend.Variable(*hashBigInt)
return poseidon.PoseidonBN128HashOut(hashVar)
}
func TestChallengerWitness(t *testing.T) {
assert := test.NewAssert(t)
testCase := func(
publicInputs [3]frontend.Variable,
circuitDigest [4]frontend.Variable,
wiresCap [16][4]frontend.Variable,
plonkZsPartialProductsCap [16][4]frontend.Variable,
quotientPolysCap [16][4]frontend.Variable,
publicInputs []field.F,
circuitDigest poseidon.PoseidonBN128HashOut,
wiresCap [16]poseidon.PoseidonBN128HashOut,
plonkZsPartialProductsCap [16]poseidon.PoseidonBN128HashOut,
quotientPolysCap [16]poseidon.PoseidonBN128HashOut,
) {
circuit := TestChallengerCircuit{
PublicInputs: publicInputs,
@@ -146,80 +126,63 @@ func TestChallengerWitness(t *testing.T) {
assert.NoError(err)
}
publicInputsStr := []string{"0", "1", "3736710860384812976"}
circuitDigestStr := []string{"7754113318730736048", "18436136620016916513", "18054530212389526288", "5893739326632906028"}
wiresCapStr := [][]string{
{"13884351014873073118", "5174249846243191862", "2208632528791973868", "1071582828677910652"},
{"11475361245556894879", "14867351574926692044", "17013374066934071379", "1027671036932569748"},
{"5604634992452399010", "3684464596850094189", "5565599237356852406", "4136295609943151014"},
{"8463721840990025805", "5922588965472526198", "8096699027533803435", "2210089353004111478"},
{"17531628199677307555", "11513452064460680964", "1482441508929181375", "5139566233781982440"},
{"13271417993289093233", "17257193898955790413", "16883807866578566670", "7423179920948669117"},
{"13462567520785358202", "15555103598281658890", "5859961276885232601", "4464568704709749394"},
{"153012620162729043", "14072764618167122665", "3025694603779494447", "15948104906680148838"},
{"18050235253694287284", "11467396424826912141", "11302553396166323353", "10976271719722841224"},
{"15208241660644051470", "8520722208187871063", "10775022596056682771", "16048513824198271730"},
{"6929477084755896240", "11382029470138215117", "13205948643259905511", "9421863267852221772"},
{"15449187573546292268", "10216729601353604194", "9493934392442974211", "9848643714440191835"},
{"2172475758127444753", "16681095938683502188", "9983383760611275566", "2603547977557388755"},
{"17440301588003279095", "11799356585691460705", "1386003375936412946", "11059100806278290279"},
{"10758265002546797581", "1374136260999724547", "7200401521491969338", "219493657547391496"},
{"5995963332181008902", "4442996285152250372", "2005936434281221193", "6869325719052666642"},
}
plonkZsPartialProductsCapStr := [][]string{
{"1209867952068639569", "4958824272276746373", "8278739766347565702", "1966940898171663504"},
{"12599305286358028697", "8932511136775685440", "5376267558248004641", "6313904687311555884"},
{"11190791343943249124", "4016631697385248176", "10356629842603047568", "10968099068686195317"},
{"1963983823153667719", "6333891613271539690", "12318891063769180636", "10443318253972130654"},
{"7799898099378084347", "2751829638242157622", "8351904444410446701", "5284662773710644867"},
{"1588568181448440843", "10836321455257423751", "5543952383542989142", "12946954522116753258"},
{"15710202198621978057", "13746115173212319217", "6103259182317700987", "17589471289629134988"},
{"12877950969971815168", "4963889190939310439", "8868772654550990048", "11774978531783219015"},
{"16832740767463005599", "15040340114131672027", "7469306538360789573", "3154855824233652432"},
{"9383568437827143152", "1741060064145647394", "17668587021570420286", "5241789470902809114"},
{"2087729156816989530", "8248918881937854542", "8673194597758568216", "10710697836634846115"},
{"11253371860840267365", "16818881664594712299", "11933553751682199585", "1936353232880935379"},
{"12163553231829171860", "17244267969759347515", "2003902333564157189", "6934019871173840760"},
{"2082141893879862527", "18267460725569427782", "1129651898415533808", "14011240934155569890"},
{"2526273401266876282", "6955959191669943337", "5926536548217021446", "17949337312612691782"},
{"8858882459906353593", "5813258279939597857", "6320047506247573502", "15969724232572328561"},
}
quotientPolysCapStr := [][]string{
{"9435614145733021495", "1742717829476348934", "11178548223985487003", "14531951007568589725"},
{"11747844681527676730", "3089691012847802165", "5887135310661642077", "13943570416123664971"},
{"11150071448774479229", "4486829025930200476", "9369448886033958276", "15757606153229850783"},
{"14603194410536469617", "11776185929725558373", "3122936423686490326", "10128277488128872810"},
{"4990578700975083076", "4997575606014863069", "14499603187047727337", "14028694557236527137"},
{"2279147899956815983", "16034899207717647338", "14763350037932939672", "10075834812570828076"},
{"1102006741007271956", "15242779529961262072", "6900547375301951311", "8631780317175902419"},
{"6299112770394539219", "6297397453582105768", "14148031335065995704", "3794733067587629405"},
{"7891039548997763820", "4260484126440019022", "6493066317319943586", "14775252570136307979"},
{"10790514248728420789", "14444029601980227412", "17514190309172155536", "12973059492411164965"},
{"8940755416742726696", "8469566845539112244", "7642612722784522739", "15276772682665052607"},
{"18306931819862706026", "14374659904694625207", "8609543532143656606", "17350044275494282679"},
{"9062024023737444614", "13780128979028684176", "6115495431779737008", "7170446003855284754"},
{"6191400598853400595", "7806485717076924017", "3225145303141729264", "3644550749005104128"},
{"15759718266801608721", "2406060174022670585", "15679263832775538866", "18066847192985300443"},
{"9184823221361582966", "4767786405185004644", "9827047623720647370", "993615002460432327"},
}
publicInputs := []field.F{}
var publicInputs [3]frontend.Variable
var circuitDigest [4]frontend.Variable
var wiresCap [16][4]frontend.Variable
var plonkZsPartialProductsCap [16][4]frontend.Variable
var quotientPolysCap [16][4]frontend.Variable
circuitDigest := StringToBN128Hash("11532502846882484230992726008257788785937565673229400981185786126842727172973")
copy(publicInputs[:], utils.StrArrayToFrontendVariableArray(publicInputsStr))
copy(circuitDigest[:], utils.StrArrayToFrontendVariableArray(circuitDigestStr))
for i := 0; i < len(wiresCapStr); i++ {
copy(wiresCap[i][:], utils.StrArrayToFrontendVariableArray(wiresCapStr[i]))
}
for i := 0; i < len(plonkZsPartialProductsCapStr); i++ {
copy(plonkZsPartialProductsCap[i][:], utils.StrArrayToFrontendVariableArray(plonkZsPartialProductsCapStr[i]))
}
for i := 0; i < len(quotientPolysCapStr); i++ {
copy(quotientPolysCap[i][:], utils.StrArrayToFrontendVariableArray(quotientPolysCapStr[i]))
}
wiresCaps := [16]poseidon.PoseidonBN128HashOut{}
wiresCaps[0] = StringToBN128Hash("6232016528318542211523647364792867346449137823066292895075623303633330508214")
wiresCaps[1] = StringToBN128Hash("3849229275985461680629770572508259203226163621677714310355251582693130685288")
wiresCaps[2] = StringToBN128Hash("5987556171512366759354088598227343740440477791444099795740854232780130336082")
wiresCaps[3] = StringToBN128Hash("8523377779888975334090507575349048869294640263235559121841789718805736414837")
wiresCaps[4] = StringToBN128Hash("4173305429039088756536564029627250985745421317354666614089039608061166671898")
wiresCaps[5] = StringToBN128Hash("19514742808406256372169729907222415291809011606011679387563713660256488346125")
wiresCaps[6] = StringToBN128Hash("8519703011007005463193900985655355044586093539828702987016626948657512235078")
wiresCaps[7] = StringToBN128Hash("13337062986664638507390757043422262298890182385759661595000247205380836291424")
wiresCaps[8] = StringToBN128Hash("13956988298720968721248573872513053256190487207048215310365406791617256823071")
wiresCaps[9] = StringToBN128Hash("4139118776078237399422219240136866906229498819930564462151328936368637474741")
wiresCaps[10] = StringToBN128Hash("20010683036854145765538326917745039166608941517703057250025522185331298063240")
wiresCaps[11] = StringToBN128Hash("16542849340693186579674885260236043503488748690860552251132996633211111581047")
wiresCaps[12] = StringToBN128Hash("15340310232736118098606223218073833983285921571850333937460777227732109309104")
wiresCaps[13] = StringToBN128Hash("14370557250059545670244193708996703450518439828341533154117610442161777001185")
wiresCaps[14] = StringToBN128Hash("18844434454299441334771065219656682212700835025465734281792408139929868142021")
wiresCaps[15] = StringToBN128Hash("19676343740377898318702605893881480074303742058989194823248293456630167789460")
testCase(publicInputs, circuitDigest, wiresCap, plonkZsPartialProductsCap, quotientPolysCap)
plonkZsPartialProductsCaps := [16]poseidon.PoseidonBN128HashOut{}
plonkZsPartialProductsCaps[0] = StringToBN128Hash("18630303757724954689095079665308152603926320437432442392614316813333911252124")
plonkZsPartialProductsCaps[1] = StringToBN128Hash("1941509032097423911575973752610668722198580889286836043016771886256831254944")
plonkZsPartialProductsCaps[2] = StringToBN128Hash("6147898094056673441182607282006528423230906496770003193057422314911254596722")
plonkZsPartialProductsCaps[3] = StringToBN128Hash("8711744418341460096856191310559061094028644913424948320707020455945693390966")
plonkZsPartialProductsCaps[4] = StringToBN128Hash("3170507894509162329082713944669012510679535839018490515228566075949014704871")
plonkZsPartialProductsCaps[5] = StringToBN128Hash("9513443633020527244719737008971091746535961947215556968735061932963144145728")
plonkZsPartialProductsCaps[6] = StringToBN128Hash("16440622144490342815400399751667969445057099157732990266662948140364680211732")
plonkZsPartialProductsCaps[7] = StringToBN128Hash("16904904288584890809819587275120157893767917607795020298373538872373275028362")
plonkZsPartialProductsCaps[8] = StringToBN128Hash("1322883689945010694042124537248103086068476085787048131689196755087178475099")
plonkZsPartialProductsCaps[9] = StringToBN128Hash("3859729225679954076862546769780866075152550721517632074656261209033111218654")
plonkZsPartialProductsCaps[10] = StringToBN128Hash("5995885491698588595978721670502011088690021401297557688057158353938846681398")
plonkZsPartialProductsCaps[11] = StringToBN128Hash("16957177478856199232404038751327729781816109007496656232207408246975862260922")
plonkZsPartialProductsCaps[12] = StringToBN128Hash("9422393668093911702915740702404346320943009100616501740579421944206639410155")
plonkZsPartialProductsCaps[13] = StringToBN128Hash("15680345727093646870610240619814271686346382346107751208797654607051065248818")
plonkZsPartialProductsCaps[14] = StringToBN128Hash("4939261448468032698521878059774016528161329965101885352386001950329280576201")
plonkZsPartialProductsCaps[15] = StringToBN128Hash("7003946111898359335505647195128523292498498760325513092978040051648331398446")
quotientPolysCaps := [16]poseidon.PoseidonBN128HashOut{}
quotientPolysCaps[0] = StringToBN128Hash("3918560082526903400389798118659365477465402367561322989181693953047280669646")
quotientPolysCaps[1] = StringToBN128Hash("496966935842756068593963213547105605432646958081400837931911611833297095727")
quotientPolysCaps[2] = StringToBN128Hash("8683297895986438077633020202252074142721819824824948690853505463451806801507")
quotientPolysCaps[3] = StringToBN128Hash("14623770060934618886104076268225324888644340537717836901769942847173950269850")
quotientPolysCaps[4] = StringToBN128Hash("902377468311802642056170073282349607767917979325737018777782566011948776523")
quotientPolysCaps[5] = StringToBN128Hash("12124340721627925810131860890689432371048624670798932303474977401990312142398")
quotientPolysCaps[6] = StringToBN128Hash("21656753786114693289615694183370749990935753681953197920766927707640495235100")
quotientPolysCaps[7] = StringToBN128Hash("4651674172794111060599611529192263627230814664669763852917839857516619530510")
quotientPolysCaps[8] = StringToBN128Hash("13161231355626784301812735677481006076469384200800574341495987998366265598910")
quotientPolysCaps[9] = StringToBN128Hash("20853590455948262404101100028402584187982204016660952863575312077951992942329")
quotientPolysCaps[10] = StringToBN128Hash("742867642166478273564934628555265381154191517824405375118170559554873960389")
quotientPolysCaps[11] = StringToBN128Hash("17617970388755497287414457313283777609067524774358298322461931046141926005038")
quotientPolysCaps[12] = StringToBN128Hash("55496208750959228576253470708262329602643441253143570259294790484739321332")
quotientPolysCaps[13] = StringToBN128Hash("18450079114184018679423491604333957974306902732410122012117555285853099024676")
quotientPolysCaps[14] = StringToBN128Hash("14403337493956171864251492809058241138806636992110526018123749007090024780352")
quotientPolysCaps[15] = StringToBN128Hash("252265115458024097842043026135110356285192501597856208375838682286051476335")
testCase(publicInputs, circuitDigest, wiresCaps, plonkZsPartialProductsCaps, quotientPolysCaps)
}

View File

@@ -187,7 +187,7 @@ func (p *PlonkChip) evalVanishingPoly(vars gates.EvaluationVars, proofChallenges
return reducedValues
}
func (p *PlonkChip) Verify(proofChallenges common.ProofChallenges, openings common.OpeningSet, publicInputsHash poseidon.Hash) {
func (p *PlonkChip) Verify(proofChallenges common.ProofChallenges, openings common.OpeningSet, publicInputsHash poseidon.PoseidonHashOut) {
// Calculate zeta^n
zetaPowN := p.expPowerOf2Extension(proofChallenges.PlonkZeta)

View File

@@ -38,31 +38,14 @@ func (circuit *TestPlonkCircuit) Define(api frontend.API) error {
return nil
}
func TestPlonkFibonacci(t *testing.T) {
func TestPlonkDecodeBlock(t *testing.T) {
assert := test.NewAssert(t)
testCase := func() {
circuit := TestPlonkCircuit{
proofWithPIsFilename: "./data/fibonacci/proof_with_public_inputs.json",
commonCircuitDataFilename: "./data/fibonacci/common_circuit_data.json",
verifierOnlyCircuitDataFilename: "./data/fibonacci/verifier_only_circuit_data.json",
}
witness := TestPlonkCircuit{}
err := test.IsSolved(&circuit, &witness, field.TEST_CURVE.ScalarField())
assert.NoError(err)
}
testCase()
}
func TestPlonkDummy(t *testing.T) {
assert := test.NewAssert(t)
testCase := func() {
circuit := TestPlonkCircuit{
proofWithPIsFilename: "./data/dummy_2^14_gates/proof_with_public_inputs.json",
commonCircuitDataFilename: "./data/dummy_2^14_gates/common_circuit_data.json",
verifierOnlyCircuitDataFilename: "./data/dummy_2^14_gates/verifier_only_circuit_data.json",
proofWithPIsFilename: "../../data/decode_block/proof_with_public_inputs.json",
commonCircuitDataFilename: "../../data/decode_block/common_circuit_data.json",
verifierOnlyCircuitDataFilename: "../../data/decode_block/verifier_only_circuit_data.json",
}
witness := TestPlonkCircuit{}
err := test.IsSolved(&circuit, &witness, field.TEST_CURVE.ScalarField())