Check blob_to_kzg_commitment ret in python binding

This commit is contained in:
Justin Traglia 2023-01-09 11:51:05 -06:00
parent 7aa44cbd5b
commit 071bd6a704
2 changed files with 7 additions and 8 deletions

View File

@ -48,7 +48,10 @@ static PyObject* blob_to_kzg_commitment_wrap(PyObject *self, PyObject *args) {
if (k == NULL) return PyErr_NoMemory();
blob_to_kzg_commitment(k, blob, PyCapsule_GetPointer(s, "KZGSettings"));
if (blob_to_kzg_commitment(k, blob, PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
free(k);
return PyErr_Format(PyExc_RuntimeError, "blob_to_kzg_commitment failed");
}
return PyCapsule_New(k, "G1", free_G1);
}

View File

@ -2,7 +2,7 @@ from py_ecc import optimized_bls12_381 as b
from fft import fft
from multicombs import lincomb
# Generatore for the field
# Generator for the field
PRIMITIVE_ROOT = 7
MODULUS = b.curve_order
@ -35,7 +35,6 @@ def generate_setup(s, size):
#
#########################################################################################
def get_root_of_unity(order):
"""
Returns a root of unity of order "order"
@ -79,7 +78,7 @@ def eval_poly_at(p, x):
def div_polys(a, b):
"""
Long polynomial difivion for two polynomials in coefficient form
Long polynomial division for two polynomials in coefficient form
"""
a = [x for x in a]
o = []
@ -101,7 +100,6 @@ def div_polys(a, b):
#
#########################################################################################
def reverse_bit_order(n, order):
"""
Reverse the bit order of an integer n
@ -109,7 +107,6 @@ def reverse_bit_order(n, order):
assert is_power_of_two(order)
# Convert n to binary with the same number of bits as "order" - 1, then reverse its bit order
return int(('{:0' + str(order.bit_length() - 1) + 'b}').format(n)[::-1], 2)
def list_to_reverse_bit_order(l):
"""
@ -117,7 +114,6 @@ def list_to_reverse_bit_order(l):
"""
return [l[reverse_bit_order(i, len(l))] for i in range(len(l))]
#########################################################################################
#
# Converting between polynomials (in coefficient form) and data (in reverse bit order)
@ -210,7 +206,7 @@ def check_proof_multi(commitment, proof, x, ys, setup):
"""
n = len(ys)
root_of_unity = get_root_of_unity(n)
# Interpolate at a coset. Note because it is a coset, not the subgroup, we have to multiply the
# polynomial coefficients by x^i
interpolation_polynomial = fft(ys, MODULUS, root_of_unity, True)