Merge pull request #57 from jtraglia/check-ret-python-binding

Check blob_to_kzg_commitment ret in python binding
This commit is contained in:
Ramana Kumar 2023-01-09 20:05:30 -08:00 committed by GitHub
commit 7f4a8f0934
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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(); 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); 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 fft import fft
from multicombs import lincomb from multicombs import lincomb
# Generatore for the field # Generator for the field
PRIMITIVE_ROOT = 7 PRIMITIVE_ROOT = 7
MODULUS = b.curve_order MODULUS = b.curve_order
@ -35,7 +35,6 @@ def generate_setup(s, size):
# #
######################################################################################### #########################################################################################
def get_root_of_unity(order): def get_root_of_unity(order):
""" """
Returns a root of unity of order "order" Returns a root of unity of order "order"
@ -79,7 +78,7 @@ def eval_poly_at(p, x):
def div_polys(a, b): 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] a = [x for x in a]
o = [] o = []
@ -101,7 +100,6 @@ def div_polys(a, b):
# #
######################################################################################### #########################################################################################
def reverse_bit_order(n, order): def reverse_bit_order(n, order):
""" """
Reverse the bit order of an integer n Reverse the bit order of an integer n
@ -110,14 +108,12 @@ def reverse_bit_order(n, order):
# Convert n to binary with the same number of bits as "order" - 1, then reverse its bit 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) return int(('{:0' + str(order.bit_length() - 1) + 'b}').format(n)[::-1], 2)
def list_to_reverse_bit_order(l): def list_to_reverse_bit_order(l):
""" """
Convert a list between normal and reverse bit order. This operation is idempotent. Convert a list between normal and reverse bit order. This operation is idempotent.
""" """
return [l[reverse_bit_order(i, len(l))] for i in range(len(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) # Converting between polynomials (in coefficient form) and data (in reverse bit order)