ckzg 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ckzg-1.0.1/LICENSE +201 -0
- ckzg-1.0.1/MANIFEST.in +10 -0
- ckzg-1.0.1/PKG-INFO +35 -0
- ckzg-1.0.1/README.md +98 -0
- ckzg-1.0.1/bindings/python/README.md +24 -0
- ckzg-1.0.1/bindings/python/ckzg.c +258 -0
- ckzg-1.0.1/blst/.git +1 -0
- ckzg-1.0.1/blst/.gitattributes +3 -0
- ckzg-1.0.1/blst/.github/workflows/ci.yml +198 -0
- ckzg-1.0.1/blst/.github/workflows/codeql-analysis.yml +55 -0
- ckzg-1.0.1/blst/.gitignore +72 -0
- ckzg-1.0.1/blst/.lgtm.yml +21 -0
- ckzg-1.0.1/blst/.travis.yml +71 -0
- ckzg-1.0.1/blst/LICENSE +201 -0
- ckzg-1.0.1/blst/README.md +223 -0
- ckzg-1.0.1/blst/SECURITY.md +9 -0
- ckzg-1.0.1/blst/bindings/blst.h +482 -0
- ckzg-1.0.1/blst/bindings/blst.hpp +979 -0
- ckzg-1.0.1/blst/bindings/blst.swg +851 -0
- ckzg-1.0.1/blst/bindings/blst_aux.h +117 -0
- ckzg-1.0.1/blst/bindings/c#/poc.cs +79 -0
- ckzg-1.0.1/blst/bindings/c#/poc.csproj +8 -0
- ckzg-1.0.1/blst/bindings/c#/run.me +806 -0
- ckzg-1.0.1/blst/bindings/c#/supranational.blst.cs +996 -0
- ckzg-1.0.1/blst/bindings/emscripten/build.py +1202 -0
- ckzg-1.0.1/blst/bindings/emscripten/run.me +13 -0
- ckzg-1.0.1/blst/bindings/emscripten/runnable.html +54 -0
- ckzg-1.0.1/blst/bindings/emscripten/runnable.js +40 -0
- ckzg-1.0.1/blst/bindings/go/README.md +80 -0
- ckzg-1.0.1/blst/bindings/go/blst.go +3434 -0
- ckzg-1.0.1/blst/bindings/go/blst.tgo +444 -0
- ckzg-1.0.1/blst/bindings/go/blst_htoc_test.go +221 -0
- ckzg-1.0.1/blst/bindings/go/blst_miller_loop_test.go +37 -0
- ckzg-1.0.1/blst/bindings/go/blst_minpk.tgo +622 -0
- ckzg-1.0.1/blst/bindings/go/blst_minpk_test.go +699 -0
- ckzg-1.0.1/blst/bindings/go/blst_minsig_test.go +703 -0
- ckzg-1.0.1/blst/bindings/go/blst_misc.tgo +334 -0
- ckzg-1.0.1/blst/bindings/go/blst_px.tgo +707 -0
- ckzg-1.0.1/blst/bindings/go/cgo_assembly.S +1 -0
- ckzg-1.0.1/blst/bindings/go/cgo_server.c +1 -0
- ckzg-1.0.1/blst/bindings/go/generate.py +131 -0
- ckzg-1.0.1/blst/bindings/go/rb_tree.go +149 -0
- ckzg-1.0.1/blst/bindings/java/Android.mk +37 -0
- ckzg-1.0.1/blst/bindings/java/build.sh +86 -0
- ckzg-1.0.1/blst/bindings/java/run.me +21 -0
- ckzg-1.0.1/blst/bindings/java/runnable.java +67 -0
- ckzg-1.0.1/blst/bindings/node.js/binding.gyp +42 -0
- ckzg-1.0.1/blst/bindings/node.js/blst.hpp.ts +239 -0
- ckzg-1.0.1/blst/bindings/node.js/blst_wrap.py +56 -0
- ckzg-1.0.1/blst/bindings/node.js/run.me +62 -0
- ckzg-1.0.1/blst/bindings/node.js/runnable.js +44 -0
- ckzg-1.0.1/blst/bindings/node.js/runnable.ts +42 -0
- ckzg-1.0.1/blst/bindings/node.js/tsconfig.json +7 -0
- ckzg-1.0.1/blst/bindings/python/run.me +435 -0
- ckzg-1.0.1/blst/bindings/rust/Cargo.toml +68 -0
- ckzg-1.0.1/blst/bindings/rust/README.md +62 -0
- ckzg-1.0.1/blst/bindings/rust/benches/blst_benches.rs +478 -0
- ckzg-1.0.1/blst/bindings/rust/build.rs +201 -0
- ckzg-1.0.1/blst/bindings/rust/publish.sh +12 -0
- ckzg-1.0.1/blst/bindings/rust/rustfmt.toml +1 -0
- ckzg-1.0.1/blst/bindings/rust/src/bindings.rs +1409 -0
- ckzg-1.0.1/blst/bindings/rust/src/lib.rs +2028 -0
- ckzg-1.0.1/blst/bindings/rust/src/pippenger-no_std.rs +146 -0
- ckzg-1.0.1/blst/bindings/rust/src/pippenger-test_mod.rs +85 -0
- ckzg-1.0.1/blst/bindings/rust/src/pippenger.rs +419 -0
- ckzg-1.0.1/blst/bindings/vectors/hash_to_curve/BLS12381G1_XMD_SHA-256_SSWU_NU_.json +90 -0
- ckzg-1.0.1/blst/bindings/vectors/hash_to_curve/BLS12381G1_XMD_SHA-256_SSWU_RO_.json +115 -0
- ckzg-1.0.1/blst/bindings/vectors/hash_to_curve/BLS12381G2_XMD_SHA-256_SSWU_NU_.json +90 -0
- ckzg-1.0.1/blst/bindings/vectors/hash_to_curve/BLS12381G2_XMD_SHA-256_SSWU_RO_.json +115 -0
- ckzg-1.0.1/blst/bindings/vectors/hash_to_curve/README +3 -0
- ckzg-1.0.1/blst/bindings/vectors/hash_to_curve/expand_message_xmd_SHA256_256.json +78 -0
- ckzg-1.0.1/blst/bindings/vectors/hash_to_curve/expand_message_xmd_SHA256_38.json +78 -0
- ckzg-1.0.1/blst/blst_logo_small.png +0 -0
- ckzg-1.0.1/blst/build/assembly.S +116 -0
- ckzg-1.0.1/blst/build/bindings_trim.pl +40 -0
- ckzg-1.0.1/blst/build/coff/add_mod_256-armv8.S +397 -0
- ckzg-1.0.1/blst/build/coff/add_mod_256-x86_64.s +924 -0
- ckzg-1.0.1/blst/build/coff/add_mod_384-armv8.S +1056 -0
- ckzg-1.0.1/blst/build/coff/add_mod_384-x86_64.s +2510 -0
- ckzg-1.0.1/blst/build/coff/add_mod_384x384-x86_64.s +330 -0
- ckzg-1.0.1/blst/build/coff/ct_inverse_mod_256-armv8.S +799 -0
- ckzg-1.0.1/blst/build/coff/ct_inverse_mod_256-x86_64.s +1213 -0
- ckzg-1.0.1/blst/build/coff/ct_inverse_mod_384-armv8.S +730 -0
- ckzg-1.0.1/blst/build/coff/ct_is_square_mod_384-armv8.S +335 -0
- ckzg-1.0.1/blst/build/coff/ct_is_square_mod_384-x86_64.s +509 -0
- ckzg-1.0.1/blst/build/coff/ctq_inverse_mod_384-x86_64.s +1230 -0
- ckzg-1.0.1/blst/build/coff/ctx_inverse_mod_384-x86_64.s +1601 -0
- ckzg-1.0.1/blst/build/coff/div3w-armv8.S +94 -0
- ckzg-1.0.1/blst/build/coff/div3w-x86_64.s +248 -0
- ckzg-1.0.1/blst/build/coff/mul_mont_256-armv8.S +474 -0
- ckzg-1.0.1/blst/build/coff/mul_mont_384-armv8.S +2424 -0
- ckzg-1.0.1/blst/build/coff/mulq_mont_256-x86_64.s +897 -0
- ckzg-1.0.1/blst/build/coff/mulq_mont_384-x86_64.s +4303 -0
- ckzg-1.0.1/blst/build/coff/mulx_mont_256-x86_64.s +796 -0
- ckzg-1.0.1/blst/build/coff/mulx_mont_384-x86_64.s +3608 -0
- ckzg-1.0.1/blst/build/coff/sha256-armv8.S +1093 -0
- ckzg-1.0.1/blst/build/coff/sha256-portable-x86_64.s +1792 -0
- ckzg-1.0.1/blst/build/coff/sha256-x86_64.s +1562 -0
- ckzg-1.0.1/blst/build/elf/add_mod_256-armv8.S +379 -0
- ckzg-1.0.1/blst/build/elf/add_mod_256-x86_64.s +572 -0
- ckzg-1.0.1/blst/build/elf/add_mod_384-armv8.S +1000 -0
- ckzg-1.0.1/blst/build/elf/add_mod_384-x86_64.s +1907 -0
- ckzg-1.0.1/blst/build/elf/add_mod_384x384-x86_64.s +252 -0
- ckzg-1.0.1/blst/build/elf/ct_inverse_mod_256-armv8.S +785 -0
- ckzg-1.0.1/blst/build/elf/ct_inverse_mod_256-x86_64.s +1186 -0
- ckzg-1.0.1/blst/build/elf/ct_inverse_mod_384-armv8.S +718 -0
- ckzg-1.0.1/blst/build/elf/ct_is_square_mod_384-armv8.S +325 -0
- ckzg-1.0.1/blst/build/elf/ct_is_square_mod_384-x86_64.s +480 -0
- ckzg-1.0.1/blst/build/elf/ctq_inverse_mod_384-x86_64.s +1201 -0
- ckzg-1.0.1/blst/build/elf/ctx_inverse_mod_384-x86_64.s +1576 -0
- ckzg-1.0.1/blst/build/elf/div3w-armv8.S +88 -0
- ckzg-1.0.1/blst/build/elf/div3w-x86_64.s +132 -0
- ckzg-1.0.1/blst/build/elf/mul_mont_256-armv8.S +464 -0
- ckzg-1.0.1/blst/build/elf/mul_mont_384-armv8.S +2372 -0
- ckzg-1.0.1/blst/build/elf/mulq_mont_256-x86_64.s +731 -0
- ckzg-1.0.1/blst/build/elf/mulq_mont_384-x86_64.s +3681 -0
- ckzg-1.0.1/blst/build/elf/mulx_mont_256-x86_64.s +631 -0
- ckzg-1.0.1/blst/build/elf/mulx_mont_384-x86_64.s +2983 -0
- ckzg-1.0.1/blst/build/elf/sha256-armv8.S +1083 -0
- ckzg-1.0.1/blst/build/elf/sha256-portable-x86_64.s +1758 -0
- ckzg-1.0.1/blst/build/elf/sha256-x86_64.s +1455 -0
- ckzg-1.0.1/blst/build/mach-o/add_mod_256-armv8.S +379 -0
- ckzg-1.0.1/blst/build/mach-o/add_mod_256-x86_64.s +564 -0
- ckzg-1.0.1/blst/build/mach-o/add_mod_384-armv8.S +1000 -0
- ckzg-1.0.1/blst/build/mach-o/add_mod_384-x86_64.s +1899 -0
- ckzg-1.0.1/blst/build/mach-o/add_mod_384x384-x86_64.s +244 -0
- ckzg-1.0.1/blst/build/mach-o/ct_inverse_mod_256-armv8.S +785 -0
- ckzg-1.0.1/blst/build/mach-o/ct_inverse_mod_256-x86_64.s +1178 -0
- ckzg-1.0.1/blst/build/mach-o/ct_inverse_mod_384-armv8.S +718 -0
- ckzg-1.0.1/blst/build/mach-o/ct_is_square_mod_384-armv8.S +325 -0
- ckzg-1.0.1/blst/build/mach-o/ct_is_square_mod_384-x86_64.s +472 -0
- ckzg-1.0.1/blst/build/mach-o/ctq_inverse_mod_384-x86_64.s +1193 -0
- ckzg-1.0.1/blst/build/mach-o/ctx_inverse_mod_384-x86_64.s +1568 -0
- ckzg-1.0.1/blst/build/mach-o/div3w-armv8.S +88 -0
- ckzg-1.0.1/blst/build/mach-o/div3w-x86_64.s +124 -0
- ckzg-1.0.1/blst/build/mach-o/mul_mont_256-armv8.S +464 -0
- ckzg-1.0.1/blst/build/mach-o/mul_mont_384-armv8.S +2372 -0
- ckzg-1.0.1/blst/build/mach-o/mulq_mont_256-x86_64.s +723 -0
- ckzg-1.0.1/blst/build/mach-o/mulq_mont_384-x86_64.s +3673 -0
- ckzg-1.0.1/blst/build/mach-o/mulx_mont_256-x86_64.s +623 -0
- ckzg-1.0.1/blst/build/mach-o/mulx_mont_384-x86_64.s +2975 -0
- ckzg-1.0.1/blst/build/mach-o/sha256-armv8.S +1083 -0
- ckzg-1.0.1/blst/build/mach-o/sha256-portable-x86_64.s +1750 -0
- ckzg-1.0.1/blst/build/mach-o/sha256-x86_64.s +1447 -0
- ckzg-1.0.1/blst/build/refresh.sh +48 -0
- ckzg-1.0.1/blst/build/win64/add_mod_256-armv8.asm +380 -0
- ckzg-1.0.1/blst/build/win64/add_mod_256-x86_64.asm +939 -0
- ckzg-1.0.1/blst/build/win64/add_mod_384-armv8.asm +1001 -0
- ckzg-1.0.1/blst/build/win64/add_mod_384-x86_64.asm +2531 -0
- ckzg-1.0.1/blst/build/win64/add_mod_384x384-x86_64.asm +338 -0
- ckzg-1.0.1/blst/build/win64/blst.def +221 -0
- ckzg-1.0.1/blst/build/win64/ct_inverse_mod_256-armv8.asm +786 -0
- ckzg-1.0.1/blst/build/win64/ct_inverse_mod_256-x86_64.asm +1220 -0
- ckzg-1.0.1/blst/build/win64/ct_inverse_mod_384-armv8.asm +719 -0
- ckzg-1.0.1/blst/build/win64/ct_is_square_mod_384-armv8.asm +326 -0
- ckzg-1.0.1/blst/build/win64/ct_is_square_mod_384-x86_64.asm +516 -0
- ckzg-1.0.1/blst/build/win64/ctq_inverse_mod_384-x86_64.asm +1240 -0
- ckzg-1.0.1/blst/build/win64/ctx_inverse_mod_384-x86_64.asm +1609 -0
- ckzg-1.0.1/blst/build/win64/div3w-armv8.asm +89 -0
- ckzg-1.0.1/blst/build/win64/div3w-x86_64.asm +257 -0
- ckzg-1.0.1/blst/build/win64/dll.c +32 -0
- ckzg-1.0.1/blst/build/win64/mul_mont_256-armv8.asm +465 -0
- ckzg-1.0.1/blst/build/win64/mul_mont_384-armv8.asm +2373 -0
- ckzg-1.0.1/blst/build/win64/mulq_mont_256-x86_64.asm +913 -0
- ckzg-1.0.1/blst/build/win64/mulq_mont_384-x86_64.asm +4341 -0
- ckzg-1.0.1/blst/build/win64/mulx_mont_256-x86_64.asm +810 -0
- ckzg-1.0.1/blst/build/win64/mulx_mont_384-x86_64.asm +3644 -0
- ckzg-1.0.1/blst/build/win64/sha256-armv8.asm +1084 -0
- ckzg-1.0.1/blst/build/win64/sha256-x86_64.asm +1575 -0
- ckzg-1.0.1/blst/build.bat +30 -0
- ckzg-1.0.1/blst/build.sh +113 -0
- ckzg-1.0.1/blst/go.mod +3 -0
- ckzg-1.0.1/blst/src/aggregate.c +673 -0
- ckzg-1.0.1/blst/src/asm/add_mod_256-armv8.pl +412 -0
- ckzg-1.0.1/blst/src/asm/add_mod_256-x86_64.pl +547 -0
- ckzg-1.0.1/blst/src/asm/add_mod_384-armv8.pl +937 -0
- ckzg-1.0.1/blst/src/asm/add_mod_384-x86_64.pl +1500 -0
- ckzg-1.0.1/blst/src/asm/add_mod_384x384-x86_64.pl +260 -0
- ckzg-1.0.1/blst/src/asm/arm-xlate.pl +389 -0
- ckzg-1.0.1/blst/src/asm/ct_inverse_mod_256-armv8.pl +587 -0
- ckzg-1.0.1/blst/src/asm/ct_inverse_mod_256-x86_64.pl +838 -0
- ckzg-1.0.1/blst/src/asm/ct_inverse_mod_384-armv8.pl +611 -0
- ckzg-1.0.1/blst/src/asm/ct_is_square_mod_384-armv8.pl +402 -0
- ckzg-1.0.1/blst/src/asm/ct_is_square_mod_384-x86_64.pl +495 -0
- ckzg-1.0.1/blst/src/asm/ctq_inverse_mod_384-x86_64.pl +896 -0
- ckzg-1.0.1/blst/src/asm/ctx_inverse_mod_384-x86_64.pl +1001 -0
- ckzg-1.0.1/blst/src/asm/div3w-armv8.pl +122 -0
- ckzg-1.0.1/blst/src/asm/div3w-x86_64.pl +196 -0
- ckzg-1.0.1/blst/src/asm/mul_mont_256-armv8.pl +409 -0
- ckzg-1.0.1/blst/src/asm/mul_mont_384-armv8.pl +2015 -0
- ckzg-1.0.1/blst/src/asm/mulq_mont_256-x86_64.pl +537 -0
- ckzg-1.0.1/blst/src/asm/mulq_mont_384-x86_64.pl +2754 -0
- ckzg-1.0.1/blst/src/asm/mulx_mont_256-x86_64.pl +497 -0
- ckzg-1.0.1/blst/src/asm/mulx_mont_384-x86_64.pl +2417 -0
- ckzg-1.0.1/blst/src/asm/sha256-armv8.pl +547 -0
- ckzg-1.0.1/blst/src/asm/sha256-portable-x86_64.pl +341 -0
- ckzg-1.0.1/blst/src/asm/sha256-x86_64.pl +786 -0
- ckzg-1.0.1/blst/src/asm/x86_64-xlate.pl +1939 -0
- ckzg-1.0.1/blst/src/blst_t.hpp +624 -0
- ckzg-1.0.1/blst/src/bulk_addition.c +176 -0
- ckzg-1.0.1/blst/src/bytes.h +152 -0
- ckzg-1.0.1/blst/src/client_min_pk.c +17 -0
- ckzg-1.0.1/blst/src/client_min_sig.c +17 -0
- ckzg-1.0.1/blst/src/consts.c +36 -0
- ckzg-1.0.1/blst/src/consts.h +30 -0
- ckzg-1.0.1/blst/src/cpuid.c +85 -0
- ckzg-1.0.1/blst/src/e1.c +564 -0
- ckzg-1.0.1/blst/src/e2.c +638 -0
- ckzg-1.0.1/blst/src/ec_mult.h +290 -0
- ckzg-1.0.1/blst/src/ec_ops.h +787 -0
- ckzg-1.0.1/blst/src/errors.h +19 -0
- ckzg-1.0.1/blst/src/exp.c +55 -0
- ckzg-1.0.1/blst/src/exports.c +583 -0
- ckzg-1.0.1/blst/src/fields.h +116 -0
- ckzg-1.0.1/blst/src/fp12_tower.c +789 -0
- ckzg-1.0.1/blst/src/hash_to_field.c +177 -0
- ckzg-1.0.1/blst/src/keygen.c +319 -0
- ckzg-1.0.1/blst/src/map_to_g1.c +559 -0
- ckzg-1.0.1/blst/src/map_to_g2.c +444 -0
- ckzg-1.0.1/blst/src/multi_scalar.c +427 -0
- ckzg-1.0.1/blst/src/no_asm.h +1345 -0
- ckzg-1.0.1/blst/src/pairing.c +493 -0
- ckzg-1.0.1/blst/src/pentaroot-addchain.h +333 -0
- ckzg-1.0.1/blst/src/pentaroot.c +76 -0
- ckzg-1.0.1/blst/src/point.h +62 -0
- ckzg-1.0.1/blst/src/rb_tree.c +145 -0
- ckzg-1.0.1/blst/src/recip-addchain.h +489 -0
- ckzg-1.0.1/blst/src/recip.c +139 -0
- ckzg-1.0.1/blst/src/server.c +30 -0
- ckzg-1.0.1/blst/src/sha256.h +140 -0
- ckzg-1.0.1/blst/src/sqrt-addchain.h +489 -0
- ckzg-1.0.1/blst/src/sqrt.c +261 -0
- ckzg-1.0.1/blst/src/vect.c +176 -0
- ckzg-1.0.1/blst/src/vect.h +418 -0
- ckzg-1.0.1/ckzg.egg-info/PKG-INFO +35 -0
- ckzg-1.0.1/ckzg.egg-info/SOURCES.txt +250 -0
- ckzg-1.0.1/ckzg.egg-info/dependency_links.txt +1 -0
- ckzg-1.0.1/ckzg.egg-info/top_level.txt +1 -0
- ckzg-1.0.1/inc/.gitignore +4 -0
- ckzg-1.0.1/lib/.gitignore +4 -0
- ckzg-1.0.1/setup.cfg +4 -0
- ckzg-1.0.1/setup.py +53 -0
- ckzg-1.0.1/src/.clang-format +12 -0
- ckzg-1.0.1/src/Makefile +168 -0
- ckzg-1.0.1/src/PROFILE.md +81 -0
- ckzg-1.0.1/src/c_kzg_4844.c +1807 -0
- ckzg-1.0.1/src/c_kzg_4844.h +187 -0
- ckzg-1.0.1/src/test_c_kzg_4844.c +1931 -0
- ckzg-1.0.1/src/tinytest.h +112 -0
- ckzg-1.0.1/src/trusted_setup.txt +4163 -0
ckzg-1.0.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
ckzg-1.0.1/MANIFEST.in
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# This is a manifest for the Python bindings
|
|
2
|
+
include bindings/python/ckzg.c
|
|
3
|
+
include bindings/python/README.md
|
|
4
|
+
recursive-include blst *
|
|
5
|
+
recursive-include lib *
|
|
6
|
+
recursive-include inc *
|
|
7
|
+
recursive-include src *
|
|
8
|
+
include setup.py
|
|
9
|
+
include LICENSE
|
|
10
|
+
include README.md
|
ckzg-1.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ckzg
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Python bindings for C-KZG-4844
|
|
5
|
+
Home-page: https://github.com/ethereum/c-kzg-4844
|
|
6
|
+
Author: Ethereum Foundation
|
|
7
|
+
Author-email: security@ethereum.org
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
|
|
12
|
+
# Python bindings
|
|
13
|
+
|
|
14
|
+
This directory contains Python bindings for the C-KZG-4844 library.
|
|
15
|
+
|
|
16
|
+
## Prerequisites
|
|
17
|
+
|
|
18
|
+
These bindings require `python3` and `PyYAML`.
|
|
19
|
+
```
|
|
20
|
+
sudo apt install python3 python3-pip
|
|
21
|
+
python3 -m pip install PyYAML
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Build & test
|
|
25
|
+
|
|
26
|
+
Everything is consolidated into one command:
|
|
27
|
+
```
|
|
28
|
+
make
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You should expect to see these messages at the bottom:
|
|
32
|
+
```
|
|
33
|
+
python3 tests.py
|
|
34
|
+
tests passed
|
|
35
|
+
```
|
ckzg-1.0.1/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# C-KZG-4844
|
|
2
|
+
|
|
3
|
+
A minimal implementation of the [Polynomial
|
|
4
|
+
Commitments](https://github.com/ethereum/consensus-specs/blob/dev/specs/deneb/polynomial-commitments.md)
|
|
5
|
+
API for EIP-4844, written in C.
|
|
6
|
+
|
|
7
|
+
## Bindings
|
|
8
|
+
|
|
9
|
+
While the core implementation is in C, bindings are available for various
|
|
10
|
+
high-level languages, providing convenient wrappers around C functions. These
|
|
11
|
+
bindings are intended to be used by Ethereum clients, to avoid re-implementation
|
|
12
|
+
of crucial cryptographic functions.
|
|
13
|
+
|
|
14
|
+
| Language | Link |
|
|
15
|
+
|----------|--------------------------------------|
|
|
16
|
+
| C# | [README](bindings/csharp/README.md) |
|
|
17
|
+
| Go | [README](bindings/go/README.md) |
|
|
18
|
+
| Java | [README](bindings/java/README.md) |
|
|
19
|
+
| Nim | [README](bindings/nim/README.md) |
|
|
20
|
+
| Node.js | [README](bindings/node.js/README.md) |
|
|
21
|
+
| Python | [README](bindings/python/README.md) |
|
|
22
|
+
| Rust | [README](bindings/rust/README.md) |
|
|
23
|
+
|
|
24
|
+
## Interface functions
|
|
25
|
+
|
|
26
|
+
The C-KZG-4844 library provides implementations of the public KZG functions that
|
|
27
|
+
are defined in the Polynomial Commitments specification. The aim is to align
|
|
28
|
+
these functions as closely as possible with the specification.
|
|
29
|
+
|
|
30
|
+
- `blob_to_kzg_commitment`
|
|
31
|
+
- `compute_kzg_proof`
|
|
32
|
+
- `compute_blob_kzg_proof`
|
|
33
|
+
- `verify_kzg_proof`
|
|
34
|
+
- `verify_blob_kzg_proof`
|
|
35
|
+
- `verify_blob_kzg_proof_batch`
|
|
36
|
+
|
|
37
|
+
This library also provides functions for loading and freeing the trusted setup,
|
|
38
|
+
which are not defined in the specification. These functions are intended to be
|
|
39
|
+
executed once during the initialization process. As the name suggests, the
|
|
40
|
+
[trusted setup
|
|
41
|
+
file](https://github.com/ethereum/c-kzg-4844/blob/main/src/trusted_setup.txt) is
|
|
42
|
+
considered to be trustworthy.
|
|
43
|
+
|
|
44
|
+
- `load_trusted_setup`
|
|
45
|
+
- `load_trusted_setup_file`
|
|
46
|
+
- `free_trusted_setup`
|
|
47
|
+
|
|
48
|
+
## Remarks
|
|
49
|
+
|
|
50
|
+
### Tests
|
|
51
|
+
|
|
52
|
+
All the bindings are tested against the [KZG reference
|
|
53
|
+
tests](https://github.com/ethereum/consensus-spec-tests/tree/master/tests/general/deneb/kzg),
|
|
54
|
+
which are defined in the consensus-spec-tests. Additionally, a suite of unit
|
|
55
|
+
tests for internal C functions is located
|
|
56
|
+
[here](https://github.com/ethereum/c-kzg-4844/blob/main/src/test_c_kzg_4844.c).
|
|
57
|
+
|
|
58
|
+
### Parallelization
|
|
59
|
+
|
|
60
|
+
The interface functions in C-KZG-4844 are single-threaded for simplicity, as
|
|
61
|
+
implementing multi-threading across multiple platforms can be complex. While
|
|
62
|
+
performance is important, these functions are already quite fast and efficient.
|
|
63
|
+
For instance, `verify_blob_kzg_proof` is expected to finish in under 3ms on most
|
|
64
|
+
systems.
|
|
65
|
+
|
|
66
|
+
### Batched verification
|
|
67
|
+
|
|
68
|
+
When processing multiple blobs, `verify_blob_kzg_proof_batch` is more efficient
|
|
69
|
+
than calling `verify_blob_kzg_proof` individually. In CI tests, verifying 64
|
|
70
|
+
blobs in batch is 53% faster per blob than verifying them individually. For a
|
|
71
|
+
single blob, `verify_blob_kzg_proof_batch` calls `verify_blob_kzg_proof`, and
|
|
72
|
+
the overhead is negligible.
|
|
73
|
+
|
|
74
|
+
### Benchmarks
|
|
75
|
+
|
|
76
|
+
C-KZG-4844 does not include C benchmarks; however, some bindings (Go, Java, and
|
|
77
|
+
Rust) have their own benchmarks. Including benchmarks in the bindings offers a
|
|
78
|
+
more realistic performance estimate, as C-KZG-4844 is not expected to be used
|
|
79
|
+
outside the bindings.
|
|
80
|
+
|
|
81
|
+
### Security audit
|
|
82
|
+
|
|
83
|
+
The source code of C-KZG-4844 was audited by [Sigma
|
|
84
|
+
Prime](https://sigmaprime.io/) in June 2023. You can find the [audit
|
|
85
|
+
report](https://github.com/ethereum/c-kzg-4844/blob/main/doc/audit/Sigma_Prime_Ethereum_Foundation_KZG_Implementations_Security_Assessment.pdf)
|
|
86
|
+
in the `doc/audit/` directory.
|
|
87
|
+
|
|
88
|
+
### Why C?
|
|
89
|
+
|
|
90
|
+
The primary reason for choosing C is that
|
|
91
|
+
[blst](https://github.com/supranational/blst), the BLS12-381 signature library
|
|
92
|
+
we wanted to use, is mostly written in C. Rust was a viable alternative, but it
|
|
93
|
+
has some disadvantages. The C toolchain is ubiquitous, and it would be somewhat
|
|
94
|
+
awkward for all the bindings to depend on another toolchain, such as Rust.
|
|
95
|
+
Compared to Rust, C offers a lighter memory and binary footprint. Furthermore, C
|
|
96
|
+
serves as the de facto language for
|
|
97
|
+
[FFI](https://en.wikipedia.org/wiki/Foreign_function_interface), so we could not
|
|
98
|
+
have completely avoided using C anyway.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Python bindings
|
|
2
|
+
|
|
3
|
+
This directory contains Python bindings for the C-KZG-4844 library.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
These bindings require `python3` and `PyYAML`.
|
|
8
|
+
```
|
|
9
|
+
sudo apt install python3 python3-pip
|
|
10
|
+
python3 -m pip install PyYAML
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Build & test
|
|
14
|
+
|
|
15
|
+
Everything is consolidated into one command:
|
|
16
|
+
```
|
|
17
|
+
make
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
You should expect to see these messages at the bottom:
|
|
21
|
+
```
|
|
22
|
+
python3 tests.py
|
|
23
|
+
tests passed
|
|
24
|
+
```
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#define PY_SSIZE_T_CLEAN
|
|
2
|
+
#include <Python.h>
|
|
3
|
+
#include "c_kzg_4844.h"
|
|
4
|
+
|
|
5
|
+
static void free_KZGSettings(PyObject *c) {
|
|
6
|
+
KZGSettings *s = PyCapsule_GetPointer(c, "KZGSettings");
|
|
7
|
+
free_trusted_setup(s);
|
|
8
|
+
free(s);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static PyObject* load_trusted_setup_wrap(PyObject *self, PyObject *args) {
|
|
12
|
+
PyObject *f;
|
|
13
|
+
FILE *fp;
|
|
14
|
+
|
|
15
|
+
if (!PyArg_ParseTuple(args, "U", &f))
|
|
16
|
+
return PyErr_Format(PyExc_ValueError, "expected a string");
|
|
17
|
+
|
|
18
|
+
KZGSettings *s = (KZGSettings*)malloc(sizeof(KZGSettings));
|
|
19
|
+
if (s == NULL) return PyErr_NoMemory();
|
|
20
|
+
|
|
21
|
+
fp = fopen(PyUnicode_AsUTF8(f), "r");
|
|
22
|
+
if (fp == NULL) {
|
|
23
|
+
free(s);
|
|
24
|
+
return PyErr_Format(PyExc_RuntimeError, "error reading trusted setup");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
C_KZG_RET ret = load_trusted_setup_file(s, fp);
|
|
28
|
+
fclose(fp);
|
|
29
|
+
|
|
30
|
+
if (ret != C_KZG_OK) {
|
|
31
|
+
free(s);
|
|
32
|
+
return PyErr_Format(PyExc_RuntimeError, "error loading trusted setup");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return PyCapsule_New(s, "KZGSettings", free_KZGSettings);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static PyObject* blob_to_kzg_commitment_wrap(PyObject *self, PyObject *args) {
|
|
39
|
+
PyObject *b;
|
|
40
|
+
PyObject *s;
|
|
41
|
+
|
|
42
|
+
if (!PyArg_UnpackTuple(args, "blob_to_kzg_commitment_wrap", 2, 2, &b, &s) ||
|
|
43
|
+
!PyBytes_Check(b) ||
|
|
44
|
+
!PyCapsule_IsValid(s, "KZGSettings"))
|
|
45
|
+
return PyErr_Format(PyExc_ValueError, "expected bytes and trusted setup");
|
|
46
|
+
|
|
47
|
+
if (PyBytes_Size(b) != BYTES_PER_BLOB)
|
|
48
|
+
return PyErr_Format(PyExc_ValueError, "expected blobs to be BYTES_PER_BLOB bytes");
|
|
49
|
+
|
|
50
|
+
PyObject *out = PyBytes_FromStringAndSize(NULL, BYTES_PER_COMMITMENT);
|
|
51
|
+
if (out == NULL) return PyErr_NoMemory();
|
|
52
|
+
|
|
53
|
+
Blob *blob = (Blob *)PyBytes_AsString(b);
|
|
54
|
+
KZGCommitment *k = (KZGCommitment *)PyBytes_AsString(out);
|
|
55
|
+
if (blob_to_kzg_commitment(k, blob, PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
|
56
|
+
Py_DECREF(out);
|
|
57
|
+
return PyErr_Format(PyExc_RuntimeError, "blob_to_kzg_commitment failed");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static PyObject* compute_kzg_proof_wrap(PyObject *self, PyObject *args) {
|
|
64
|
+
PyObject *b, *z, *s;
|
|
65
|
+
|
|
66
|
+
if (!PyArg_UnpackTuple(args, "compute_kzg_proof_wrap", 3, 3, &b, &z, &s) ||
|
|
67
|
+
!PyBytes_Check(b) ||
|
|
68
|
+
!PyBytes_Check(z) ||
|
|
69
|
+
!PyCapsule_IsValid(s, "KZGSettings"))
|
|
70
|
+
return PyErr_Format(PyExc_ValueError, "expected bytes, bytes, trusted setup");
|
|
71
|
+
|
|
72
|
+
if (PyBytes_Size(b) != BYTES_PER_BLOB)
|
|
73
|
+
return PyErr_Format(PyExc_ValueError, "expected blobs to be BYTES_PER_BLOB bytes");
|
|
74
|
+
if (PyBytes_Size(z) != BYTES_PER_FIELD_ELEMENT)
|
|
75
|
+
return PyErr_Format(PyExc_ValueError, "expected blobs to be BYTES_PER_FIELD_ELEMENT bytes");
|
|
76
|
+
|
|
77
|
+
PyObject *py_y = PyBytes_FromStringAndSize(NULL, BYTES_PER_FIELD_ELEMENT);
|
|
78
|
+
if (py_y == NULL) return PyErr_NoMemory();
|
|
79
|
+
PyObject *py_proof = PyBytes_FromStringAndSize(NULL, BYTES_PER_PROOF);
|
|
80
|
+
if (py_proof == NULL) return PyErr_NoMemory();
|
|
81
|
+
|
|
82
|
+
PyObject *out = PyTuple_Pack(2, py_proof, py_y);
|
|
83
|
+
if (out == NULL) return PyErr_NoMemory();
|
|
84
|
+
|
|
85
|
+
Blob *blob = (Blob *)PyBytes_AsString(b);
|
|
86
|
+
Bytes32 *z_bytes = (Bytes32 *)PyBytes_AsString(z);
|
|
87
|
+
KZGProof *proof = (KZGProof *)PyBytes_AsString(py_proof);
|
|
88
|
+
Bytes32 *y_bytes = (Bytes32 *)PyBytes_AsString(py_y);
|
|
89
|
+
if (compute_kzg_proof(proof, y_bytes, blob, z_bytes, PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
|
90
|
+
Py_DECREF(out);
|
|
91
|
+
return PyErr_Format(PyExc_RuntimeError, "compute_kzg_proof failed");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static PyObject* compute_blob_kzg_proof_wrap(PyObject *self, PyObject *args) {
|
|
98
|
+
PyObject *b, *c, *s;
|
|
99
|
+
|
|
100
|
+
if (!PyArg_UnpackTuple(args, "compute_blob_kzg_proof_wrap", 3, 3, &b, &c, &s) ||
|
|
101
|
+
!PyBytes_Check(b) ||
|
|
102
|
+
!PyBytes_Check(c) ||
|
|
103
|
+
!PyCapsule_IsValid(s, "KZGSettings"))
|
|
104
|
+
return PyErr_Format(PyExc_ValueError, "expected bytes, bytes, trusted setup");
|
|
105
|
+
|
|
106
|
+
if (PyBytes_Size(b) != BYTES_PER_BLOB)
|
|
107
|
+
return PyErr_Format(PyExc_ValueError, "expected blobs to be BYTES_PER_BLOB bytes");
|
|
108
|
+
if (PyBytes_Size(c) != BYTES_PER_COMMITMENT)
|
|
109
|
+
return PyErr_Format(PyExc_ValueError, "expected commitment to be BYTES_PER_COMMITMENT bytes");
|
|
110
|
+
|
|
111
|
+
PyObject *out = PyBytes_FromStringAndSize(NULL, BYTES_PER_PROOF);
|
|
112
|
+
if (out == NULL) return PyErr_NoMemory();
|
|
113
|
+
|
|
114
|
+
Blob *blob = (Blob *)PyBytes_AsString(b);
|
|
115
|
+
Bytes48 *commitment_bytes = (Bytes48 *)PyBytes_AsString(c);
|
|
116
|
+
KZGProof *proof = (KZGProof *)PyBytes_AsString(out);
|
|
117
|
+
if (compute_blob_kzg_proof(proof, blob, commitment_bytes, PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
|
118
|
+
Py_DECREF(out);
|
|
119
|
+
return PyErr_Format(PyExc_RuntimeError, "compute_blob_kzg_proof failed");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static PyObject* verify_kzg_proof_wrap(PyObject *self, PyObject *args) {
|
|
126
|
+
PyObject *c, *z, *y, *p, *s;
|
|
127
|
+
|
|
128
|
+
if (!PyArg_UnpackTuple(args, "verify_kzg_proof", 5, 5, &c, &z, &y, &p, &s) ||
|
|
129
|
+
!PyBytes_Check(c) ||
|
|
130
|
+
!PyBytes_Check(z) ||
|
|
131
|
+
!PyBytes_Check(y) ||
|
|
132
|
+
!PyBytes_Check(p) ||
|
|
133
|
+
!PyCapsule_IsValid(s, "KZGSettings"))
|
|
134
|
+
return PyErr_Format(PyExc_ValueError,
|
|
135
|
+
"expected bytes, bytes, bytes, bytes, trusted setup");
|
|
136
|
+
|
|
137
|
+
if (PyBytes_Size(c) != BYTES_PER_COMMITMENT)
|
|
138
|
+
return PyErr_Format(PyExc_ValueError, "expected commitment to be BYTES_PER_COMMITMENT bytes");
|
|
139
|
+
if (PyBytes_Size(z) != BYTES_PER_FIELD_ELEMENT)
|
|
140
|
+
return PyErr_Format(PyExc_ValueError, "expected z to be BYTES_PER_FIELD_ELEMENT bytes");
|
|
141
|
+
if (PyBytes_Size(y) != BYTES_PER_FIELD_ELEMENT)
|
|
142
|
+
return PyErr_Format(PyExc_ValueError, "expected y to be BYTES_PER_FIELD_ELEMENT bytes");
|
|
143
|
+
if (PyBytes_Size(p) != BYTES_PER_PROOF)
|
|
144
|
+
return PyErr_Format(PyExc_ValueError, "expected proof to be BYTES_PER_PROOF bytes");
|
|
145
|
+
|
|
146
|
+
const Bytes48 *commitment_bytes = (Bytes48 *)PyBytes_AsString(c);
|
|
147
|
+
const Bytes32 *z_bytes = (Bytes32 *)PyBytes_AsString(z);
|
|
148
|
+
const Bytes32 *y_bytes = (Bytes32 *)PyBytes_AsString(y);
|
|
149
|
+
const Bytes48 *proof_bytes = (Bytes48 *)PyBytes_AsString(p);
|
|
150
|
+
|
|
151
|
+
bool ok;
|
|
152
|
+
if (verify_kzg_proof(&ok,
|
|
153
|
+
commitment_bytes, z_bytes, y_bytes, proof_bytes,
|
|
154
|
+
PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
|
155
|
+
return PyErr_Format(PyExc_RuntimeError, "verify_kzg_proof failed");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (ok) Py_RETURN_TRUE; else Py_RETURN_FALSE;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static PyObject* verify_blob_kzg_proof_wrap(PyObject *self, PyObject *args) {
|
|
162
|
+
PyObject *b, *c, *p, *s;
|
|
163
|
+
|
|
164
|
+
if (!PyArg_UnpackTuple(args, "verify_blob_kzg_proof", 4, 4, &b, &c, &p, &s) ||
|
|
165
|
+
!PyBytes_Check(b) ||
|
|
166
|
+
!PyBytes_Check(c) ||
|
|
167
|
+
!PyBytes_Check(p) ||
|
|
168
|
+
!PyCapsule_IsValid(s, "KZGSettings"))
|
|
169
|
+
return PyErr_Format(PyExc_ValueError,
|
|
170
|
+
"expected bytes, bytes, bytes, trusted setup");
|
|
171
|
+
|
|
172
|
+
if (PyBytes_Size(b) != BYTES_PER_BLOB)
|
|
173
|
+
return PyErr_Format(PyExc_ValueError, "expected blob to be BYTES_PER_BLOB bytes");
|
|
174
|
+
if (PyBytes_Size(c) != BYTES_PER_COMMITMENT)
|
|
175
|
+
return PyErr_Format(PyExc_ValueError, "expected commitment to be BYTES_PER_COMMITMENT bytes");
|
|
176
|
+
if (PyBytes_Size(p) != BYTES_PER_PROOF)
|
|
177
|
+
return PyErr_Format(PyExc_ValueError, "expected proof to be BYTES_PER_PROOF bytes");
|
|
178
|
+
|
|
179
|
+
const Blob *blob_bytes = (Blob *)PyBytes_AsString(b);
|
|
180
|
+
const Bytes48 *commitment_bytes = (Bytes48 *)PyBytes_AsString(c);
|
|
181
|
+
const Bytes48 *proof_bytes = (Bytes48 *)PyBytes_AsString(p);
|
|
182
|
+
|
|
183
|
+
bool ok;
|
|
184
|
+
if (verify_blob_kzg_proof(&ok,
|
|
185
|
+
blob_bytes, commitment_bytes, proof_bytes,
|
|
186
|
+
PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
|
187
|
+
return PyErr_Format(PyExc_RuntimeError, "verify_blob_kzg_proof failed");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (ok) Py_RETURN_TRUE; else Py_RETURN_FALSE;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static PyObject* verify_blob_kzg_proof_batch_wrap(PyObject *self, PyObject *args) {
|
|
194
|
+
PyObject *b, *c, *p, *s;
|
|
195
|
+
|
|
196
|
+
if (!PyArg_UnpackTuple(args, "verify_blob_kzg_proof_batch", 4, 4, &b, &c, &p, &s) ||
|
|
197
|
+
!PyBytes_Check(b) ||
|
|
198
|
+
!PyBytes_Check(c) ||
|
|
199
|
+
!PyBytes_Check(p) ||
|
|
200
|
+
!PyCapsule_IsValid(s, "KZGSettings"))
|
|
201
|
+
return PyErr_Format(PyExc_ValueError,
|
|
202
|
+
"expected bytes, bytes, bytes, trusted setup");
|
|
203
|
+
|
|
204
|
+
Py_ssize_t blobs_count = PyBytes_Size(b);
|
|
205
|
+
if (blobs_count % BYTES_PER_BLOB != 0)
|
|
206
|
+
return PyErr_Format(PyExc_ValueError, "expected blobs to be a multiple of BYTES_PER_BLOB bytes");
|
|
207
|
+
blobs_count = blobs_count / BYTES_PER_BLOB;
|
|
208
|
+
|
|
209
|
+
Py_ssize_t commitments_count = PyBytes_Size(c);
|
|
210
|
+
if (commitments_count % BYTES_PER_COMMITMENT != 0)
|
|
211
|
+
return PyErr_Format(PyExc_ValueError, "expected commitments to be a multiple of BYTES_PER_COMMITMENT bytes");
|
|
212
|
+
commitments_count = commitments_count / BYTES_PER_COMMITMENT;
|
|
213
|
+
|
|
214
|
+
Py_ssize_t proofs_count = PyBytes_Size(p);
|
|
215
|
+
if (proofs_count % BYTES_PER_PROOF != 0)
|
|
216
|
+
return PyErr_Format(PyExc_ValueError, "expected blobs to be a multiple of BYTES_PER_PROOF bytes");
|
|
217
|
+
proofs_count = proofs_count / BYTES_PER_PROOF;
|
|
218
|
+
|
|
219
|
+
if (blobs_count != commitments_count || blobs_count != proofs_count) {
|
|
220
|
+
return PyErr_Format(PyExc_ValueError, "expected same number of blobs/commitments/proofs");
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const Blob *blobs_bytes = (Blob *)PyBytes_AsString(b);
|
|
224
|
+
const Bytes48 *commitments_bytes = (Bytes48 *)PyBytes_AsString(c);
|
|
225
|
+
const Bytes48 *proofs_bytes = (Bytes48 *)PyBytes_AsString(p);
|
|
226
|
+
|
|
227
|
+
bool ok;
|
|
228
|
+
if (verify_blob_kzg_proof_batch(&ok,
|
|
229
|
+
blobs_bytes, commitments_bytes, proofs_bytes, blobs_count,
|
|
230
|
+
PyCapsule_GetPointer(s, "KZGSettings")) != C_KZG_OK) {
|
|
231
|
+
return PyErr_Format(PyExc_RuntimeError, "verify_blob_kzg_proof_batch failed");
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (ok) Py_RETURN_TRUE; else Py_RETURN_FALSE;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static PyMethodDef ckzgmethods[] = {
|
|
238
|
+
{"load_trusted_setup", load_trusted_setup_wrap, METH_VARARGS, "Load trusted setup from file path"},
|
|
239
|
+
{"blob_to_kzg_commitment", blob_to_kzg_commitment_wrap, METH_VARARGS, "Create a commitment from a blob"},
|
|
240
|
+
{"compute_kzg_proof", compute_kzg_proof_wrap, METH_VARARGS, "Compute a proof for a blob/field"},
|
|
241
|
+
{"compute_blob_kzg_proof", compute_blob_kzg_proof_wrap, METH_VARARGS, "Compute a proof for a blob"},
|
|
242
|
+
{"verify_kzg_proof", verify_kzg_proof_wrap, METH_VARARGS, "Verify a proof for the given inputs"},
|
|
243
|
+
{"verify_blob_kzg_proof", verify_blob_kzg_proof_wrap, METH_VARARGS, "Verify a blob/commitment/proof combo"},
|
|
244
|
+
{"verify_blob_kzg_proof_batch", verify_blob_kzg_proof_batch_wrap, METH_VARARGS, "Verify multiple blob/commitment/proof combos"},
|
|
245
|
+
{NULL, NULL, 0, NULL}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
static struct PyModuleDef ckzg = {
|
|
249
|
+
PyModuleDef_HEAD_INIT,
|
|
250
|
+
"ckzg",
|
|
251
|
+
NULL,
|
|
252
|
+
-1,
|
|
253
|
+
ckzgmethods
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
PyMODINIT_FUNC PyInit_ckzg(void) {
|
|
257
|
+
return PyModule_Create(&ckzg);
|
|
258
|
+
}
|
ckzg-1.0.1/blst/.git
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gitdir: ../.git/modules/blst
|