mirror of
https://github.com/0xPARC/plonkathon.git
synced 2026-01-09 13:48:00 -05:00
add setup test
This commit is contained in:
24
setup.py
24
setup.py
@@ -66,24 +66,12 @@ class Setup(object):
|
||||
def commit(self, values: Polynomial) -> G1Point:
|
||||
assert values.basis == Basis.LAGRANGE
|
||||
|
||||
# inverse FFT from Lagrange basis to monomial basis
|
||||
coeffs = values.ifft().values
|
||||
if len(coeffs) > len(self.powers_of_x):
|
||||
raise Exception("Not enough powers in setup")
|
||||
return ec_lincomb([(s, x) for s, x in zip(self.powers_of_x, coeffs)])
|
||||
# Run inverse FFT to convert values from Lagrange basis to monomial basis
|
||||
# Optional: Check values size does not exceed maximum power setup can handle
|
||||
# Compute linear combination of setup with values
|
||||
return NotImplemented
|
||||
|
||||
# Generate the verification key for this program with the given setup
|
||||
def verification_key(self, pk: CommonPreprocessedInput) -> VerificationKey:
|
||||
return VerificationKey(
|
||||
pk.group_order,
|
||||
self.commit(pk.QM),
|
||||
self.commit(pk.QL),
|
||||
self.commit(pk.QR),
|
||||
self.commit(pk.QO),
|
||||
self.commit(pk.QC),
|
||||
self.commit(pk.S1),
|
||||
self.commit(pk.S2),
|
||||
self.commit(pk.S3),
|
||||
self.X2,
|
||||
Scalar.root_of_unity(pk.group_order),
|
||||
)
|
||||
# Create the appropriate VerificationKey object
|
||||
return NotImplemented
|
||||
|
||||
12
test.py
12
test.py
@@ -1,4 +1,6 @@
|
||||
from compiler.program import Program
|
||||
from curve import G1Point
|
||||
from poly import Basis, Polynomial
|
||||
from setup import Setup
|
||||
from prover import Prover
|
||||
from verifier import VerificationKey
|
||||
@@ -6,6 +8,15 @@ import json
|
||||
from test.mini_poseidon import rc, mds, poseidon_hash
|
||||
from utils import *
|
||||
|
||||
def setup_test():
|
||||
setup = Setup.from_file("test/powersOfTau28_hez_final_11.ptau")
|
||||
dummy_values = Polynomial(list(map(Scalar, [1, 2, 3, 4, 5, 6, 7, 8])), Basis.LAGRANGE)
|
||||
program = Program(["c <== a * b"], 8)
|
||||
commitment = setup.commit(dummy_values)
|
||||
assert commitment == G1Point((16120260411117808045030798560855586501988622612038310041007562782458075125622, 3125847109934958347271782137825877642397632921923926105820408033549219695465))
|
||||
vk = setup.verification_key(program.common_preprocessed_input())
|
||||
assert vk.w == 19540430494807482326159819597004422086093766032135589407132600596362845576832
|
||||
print("Successfully created dummy commitment and verification key")
|
||||
|
||||
def basic_test():
|
||||
# Extract 2^28 powers of tau
|
||||
@@ -175,6 +186,7 @@ def poseidon_test(setup):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_test()
|
||||
setup = basic_test()
|
||||
ab_plus_a_test(setup)
|
||||
one_public_input_test(setup)
|
||||
|
||||
Reference in New Issue
Block a user