第13回zk部
Step 1: Implement setup.py
以下のコードでテスト通ります。
code:commit
def commit(self, values: Polynomial) -> G1Point:
assert values.basis == Basis.LAGRANGE
coefs = values.ifft()
pairs = list(zip(self.powers_of_x, coefs.values))
# 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 ec_lincomb(pairs)
code::verification_key
# Generate the verification key for this program with the given setup
def verification_key(self, pk: CommonPreprocessedInput) -> VerificationKey:
# Create the appropriate VerificationKey object
verificationKey = 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)
)