Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yiğit's attempt #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions prover.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,22 @@ def round_1(
# - A_values: witness[program.wires()[i].L]
# - B_values: witness[program.wires()[i].R]
# - C_values: witness[program.wires()[i].O]
filler = [Scalar(0) for i in range(self.group_order - len(program.wires()))]

A_values = [Scalar(witness[program.wires()[i].L]) for i in range(len(program.wires()))] + filler
B_values = [Scalar(witness[program.wires()[i].R]) for i in range(len(program.wires()))] + filler
C_values = [Scalar(witness[program.wires()[i].O]) for i in range(len(program.wires()))] + filler

# Construct A, B, C Lagrange interpolation polynomials for
# A_values, B_values, C_values
self.A = Polynomial(A_values, Basis.LAGRANGE)
self.B = Polynomial(B_values, Basis.LAGRANGE)
self.C = Polynomial(C_values, Basis.LAGRANGE)

# Compute a_1, b_1, c_1 commitments to A, B, C polynomials
a_1 = setup.commit(self.A)
b_1 = setup.commit(self.B)
c_1 = setup.commit(self.C)

# Sanity check that witness fulfils gate constraints
assert (
Expand Down Expand Up @@ -313,3 +324,4 @@ def expanded_evals_to_coeffs(self, x: Polynomial):

def rlc(self, term_1, term_2):
return term_1 + term_2 * self.beta + self.gamma

20 changes: 18 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,27 @@ def commit(self, values: Polynomial) -> G1Point:
assert values.basis == Basis.LAGRANGE

# Run inverse FFT to convert values from Lagrange basis to monomial basis
monomial_version = values.ifft()
# Optional: Check values size does not exceed maximum power setup can handle
# Compute linear combination of setup with values
return NotImplemented
commitment = ec_lincomb(list(zip(self.powers_of_x, monomial_version.values)))

return commitment

# Generate the verification key for this program with the given setup
def verification_key(self, pk: CommonPreprocessedInput) -> VerificationKey:
# Create the appropriate VerificationKey object
return NotImplemented
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)
)