diff --git a/min-bindings/python/Makefile b/min-bindings/python/Makefile index e22c9c9..5bd50c3 100644 --- a/min-bindings/python/Makefile +++ b/min-bindings/python/Makefile @@ -1,6 +1,10 @@ INCLUDE_DIRS = .. ../../min-src ../../inc INCLUDE_PY = $(shell python -c 'import sysconfig; print(sysconfig.get_config_var("INCLUDEPY"))') +.PHONY: all + +all: test ecc_test + test: tests.py ckzg.so python $< diff --git a/min-bindings/python/py_ecc_tests.py b/min-bindings/python/py_ecc_tests.py index 2faf255..da5cc2f 100644 --- a/min-bindings/python/py_ecc_tests.py +++ b/min-bindings/python/py_ecc_tests.py @@ -1,11 +1,9 @@ -import atexit import ckzg import kzg_proofs import random from py_ecc import optimized_bls12_381 as b from py_ecc.bls.point_compression import compress_G1, decompress_G1, decompress_G2 - polynomial = [random.randint(0, kzg_proofs.MODULUS) for i in range(4096)] n = len(polynomial) @@ -74,3 +72,5 @@ proof_pyecc = kzg_proofs.compute_proof_single(polynomial, x, ts_pyecc) proof_ckzg = ckzg.compute_kzg_proof(ckzg_poly, ckzg.bytes_to_bls_field(x.to_bytes(32, "little")), ts) assert compress_G1(proof_pyecc).to_bytes(48, "big") == ckzg.bytes_from_g1(proof_ckzg) + +print('comparison to py_ecc passed') diff --git a/min-bindings/python/tests.py b/min-bindings/python/tests.py index 0cc83dd..c9d5326 100644 --- a/min-bindings/python/tests.py +++ b/min-bindings/python/tests.py @@ -7,6 +7,8 @@ import ssz bs = (329).to_bytes(32, "little") assert 329 == ckzg.int_from_bls_field(ckzg.bytes_to_bls_field(bs)) +del bs + # Simple test of compute_powers x = 32930439 @@ -20,6 +22,8 @@ for p in powers: p_check *= x p_check %= 2**256 +del x, n, powers, p_check + # Simple test of polynomial evaluation ts = ckzg.load_trusted_setup("tiny_trusted_setup.txt") @@ -45,7 +49,10 @@ MAX_BLOBS_PER_BLOCK = 16 blobs_sedes = ssz.List(ssz.Vector(ssz.uint256, BLOB_SIZE), MAX_BLOBS_PER_BLOCK) kzg_commitments_sedes = ssz.List(ssz.bytes48, MAX_BLOBS_PER_BLOCK) -blobs = [[ckzg.bytes_to_bls_field(random.randbytes(32)) for _ in range(BLOB_SIZE)] for _ in range(3)] +blobs = [ + [ckzg.bytes_to_bls_field(random.randbytes(32)) for _ in range(BLOB_SIZE)] + for _ in range(3) +] ts = ckzg.load_trusted_setup("../../src/trusted_setup.txt")