Commit Graph

303 Commits

Author SHA1 Message Date
Gottfried Herold 93714c2a8c
changed VLA to an explicit c_kzg_malloc - call. (#223)
VLA's are prone to cause (silent!) stack overflows and a potential cause of security vulns.
While the usage pattern is probably safe in our context, changing to a more robust solution seems prudent.
2023-03-17 06:11:45 -05:00
Gottfried Herold 51d15222c6
Documentation fix. (#227) 2023-03-17 11:54:19 +02:00
George Kadianakis 903a13fb98
Simplify `fr_batch_inv` and reject zero inputs (#215) 2023-03-16 12:52:59 -05:00
Justin Traglia 2ba8f35dc4
Simplify and cleanup C code (#212) 2023-03-16 08:35:22 -05:00
George Kadianakis a1b52ac9e1
Add c_kzg_free() helper free-and-null macro (#210) 2023-03-14 09:44:03 -05:00
Gottfried Herold b4eb8d003e
Documentation updates (#208)
* Documentation update

* Documentation for division. Note that the doc says that the behaviour for a/0 is unspecified. Feel free to change.

* Add some Documentation. This fixes item #3 in https://hackmd.io/@6iQDuIePQjyYBqDChYw_jg/ByXAsi21h

* Moved documentation remark for doxygen @remark to in-code remark. The remark is not useful for API-documentation (it refers to a macro that is not part of the API).

* More verbose comment for bit_reversal_permutation.

* doxygen comment parameter name did not match variable name. Fix this.

* Remove parameter n from doxygen comment of compute_challenge, as there is no such argument.
This fixes #4 in https://hackmd.io/@6iQDuIePQjyYBqDChYw_jg/ByXAsi21h

* In compute_kzg_proof_impl, document the role of the m variable that is used to indicate whether the evaluation point is one of the interpolation points.

* Run  `make format`

* Improve multiline comments from `make format` in middle of the code

---------

Co-authored-by: George Kadianakis <desnacked@riseup.net>
2023-03-14 11:40:06 +02:00
Justin Traglia 4f0546af81
Run clang sanitizers in CI + workflow cleanup (#196)
* Run clang sanitizers in CI + workflow cleanup

* Update makefile

* Update workflow names

* Simplify more

* Run go benchmarks in CI

* Fix indentation nits

* Initialize variable in fr_is_one

* Revert "Initialize variable in fr_is_one"

This reverts commit f4c2749e410c68479f83d78c9a1780efe191c7fe.

* Move .PHONY outside of condition
2023-03-13 12:42:12 +02:00
Justin Traglia 4211d4b427
Update profiling funcs to new interface (#198) 2023-03-10 11:41:16 +02:00
Gottfried Herold fa851f1b2c
fr_batch_inv() now fails if output and input pointers alias (#185)
instead of giving wrong result with no error

Co-authored-by: George Kadianakis <desnacked@riseup.net>
2023-03-09 18:24:49 +02:00
Gottfried Herold 2548d489a6
Documentation fix: (#193)
The previous statement was slightly wrong. Being a primite root does not mean r^( (q-1)/2) != 1.
If q=1 == 2^s * t, the latter is satisfied by e.g. t'th roots of unity, but those are not primitive roots by the usual definition.
Fortunately, the actual computation of 2^i'th roots of unity does not require a primitve root to start with, only a non-square.
2023-03-09 18:11:48 +02:00
George Kadianakis 02b7855eb7
Make verify_*() functions pessimistic by default (#184) 2023-03-08 11:00:12 -06:00
Suphanat Chunhapanya ccf1a4fdf0
Change on compute_[blob_]kzg_proof function signatures (#174) 2023-03-07 13:51:43 -06:00
George Kadianakis 088b062d36
Simplify g1_mul() and make it look like g2_mul() (#179) 2023-03-07 07:54:38 -07:00
George Kadianakis 53b38face0
Fix little-endian serialization in compute_challenge() (#168) 2023-03-02 11:35:37 -07:00
Justin Traglia ae0aeaf33d
Remove duplicate p1_on_curve check (#107)
Co-authored-by: George Kadianakis <desnacked@riseup.net>
2023-03-01 12:52:44 +02:00
George Kadianakis 94198b5c18
Refactor use of MSM around the base code (#159)
* Separate naive MSM and fast MSM into separate functions

* Use naive MSM in batch verify, and fast MSM when points are trusted
2023-02-24 17:38:30 +02:00
Justin Traglia 6b2ee20102
Add bindings to readme (#154)
* Add bindings section to readme

* Reorganize a little bit

* Remove extra blank lines
2023-02-23 17:53:08 +02:00
dankrad e171cb92ff
Add more unit tests (#137) 2023-02-22 08:42:57 -06:00
Justin Traglia b04c35437f
Fix the position dependent test (#151) 2023-02-21 18:19:50 +00:00
George Kadianakis 46d529cf00
Interface changes to free the blobs (#123)
* Update C files to new interface

* Switch CHALLENGE_INPUT_SIZE from a macro to a `const int`.

* Update README with the new public methods

---------

Co-authored-by: Justin Traglia <jtraglia@pm.me>
2023-02-20 15:52:12 +00:00
Justin Traglia e93110903e
Clean up the testing file a bit (#134) 2023-02-14 21:17:55 +00:00
Justin Traglia 128dd3eb1f
Disable compiler optimizations for tests (#133) 2023-02-13 18:20:21 +00:00
Justin Traglia ef3c78ee9b
Add c_kzg_calloc function (#130)
* Add c_kzg_calloc function

* Update .gitignore & remove now unnecessary checks

* Add some tests

* Free memory in tests
2023-02-12 21:29:29 +00:00
Justin Traglia 44fe79fd42
Run static analysis in CI (#129)
* Run static analysis in CI

* Remove analysis-report in make clean

* Add remark

* Remove the memory helper functions

* Revert "Remove the memory helper functions"

This reverts commit 364234aea02cca38ed40a5bce1bbc8f8eb02aee2.

* Remove swap file
2023-02-11 16:03:35 +00:00
Justin Traglia fcea0faff6
Fix some minor nits (#128)
* Fix some minor nits

* Remove comment padding in makefile
2023-02-11 09:10:03 +00:00
Justin Traglia 5c1128e380
Add profiling (#124)
* Start to add profiling

* Add include flags for macos

* Add profiling funcs for the other funcs

* Add profiling readme

* Move sentence

* Add warning section

* Make run_profiler phony

* Delete extra empty lines

* Add line about box size

* No more dropped nodes/edges

* Remove function focus

* Add sha256 benchmark

* Benchmark sha256 with different sizes

* Clean things up a little
2023-02-10 20:33:32 +00:00
Justin Traglia dc28b03f9d
Cleanup the Makefile (#119)
* Cleanup the Makefile some

* Fix compiler error

* Fix compiler errors in tests

* Fix problems on Linux

* Add test_c_kzg_4844_cov to gitignore

* Add back closing brace for cpp

* Split clean rule into two lines

* Not echo commands when running them

* Allow other compilers to be used

* Update comment

* Only allow clang, actually
2023-02-08 17:35:33 +00:00
Justin Traglia af333c2706
Change nbits from 256 to 255 for Pippenger's method (#121) 2023-02-08 07:13:22 +00:00
Justin Traglia e487800529
Format the main C file (#116) 2023-02-07 10:35:33 +00:00
Justin Traglia 97c46a8532
Add test for compute_powers (#110)
* Add test for compute_powers

* Remove extra blank line

* Make it better

* Run make format

* Make compute powers more efficient

* Use explicit memcpy

* Fix bug in my new implementation

* Slightly cleaner implementation

* Revert changes to compute_powers

* Run formatter
2023-02-01 19:33:22 +00:00
George Kadianakis e36c11dfe2
Fix compute_kzg_proof_impl() when `z` is inside the domain (#111)
* Fix compute_kzg_proof_impl() when `z` is inside the domain

* Satisfy linter D:
2023-02-01 19:32:39 +00:00
Justin Traglia e5fa8c7ee1
Simplify log_2_byte & add test (#109) 2023-02-01 17:16:20 +00:00
Justin Traglia 1e7353c435
Run clang-format on test code (#108)
* Run clang-format on test code

* Fix format test

* Don't pack arguments

* Use more descriptive variable names
2023-02-01 14:48:29 +00:00
Justin Traglia 471245001d
Generate coverage report (#106)
* Add check for test coverage

* Add coverage html report

* Install llvm

* Save coverage report before doing check

* Update coverate report path

* Remove coverage check

* Remove coverage report in make clean

* Remove extra CFLAG
2023-02-01 07:58:52 +00:00
Justin Traglia eb17071bf3
Add some tests for reverse_bits (#105) 2023-01-31 15:51:35 +00:00
Justin Traglia d3b061f84b
Add bytes32_from_hex helper function (#103) 2023-01-31 15:48:41 +00:00
Justin Traglia ea73c3f1ca
Add some validate_kzg_g1 tests (#102) 2023-01-31 11:26:25 +00:00
George Kadianakis 9f443bc5aa
test_compute_kzg_proof() now also verifies the KZG proof (#101)
Co-authored-by: Justin Traglia <95511699+jtraglia@users.noreply.github.com>
2023-01-31 08:33:02 +00:00
Justin Traglia afd9bb78f0
Add some blob_to_kzg_commitment tests (#100)
* Add some basic blob_to_kzg_commitment tests

* Rename field_element var

* Rephrase comment

* At point_at_infinity test case

* Update comments

* Use more descriptive test names

* Update comments

* Add sections

* Add "consistent_commitment" test

* Use Bytes* types
2023-01-31 07:36:02 +00:00
Justin Traglia 3340843c91
Make get_rand_blob return a full blob (#99)
* Fix a problem in get_rand_blob

* Use bytes field instead of new var
2023-01-30 16:36:18 +00:00
Justin Traglia 05bd73bca5
Clean up the test file a little (#97) 2023-01-30 13:57:26 +00:00
Ramana Kumar 7f1fb88da9
Remove b modifier 2023-01-30 13:40:54 +00:00
George Kadianakis 98aa54a996
Add a basic unittest framework + a compute KZG proof test (#96)
* Add tinytest.h testing framework

from https://github.com/joewalnes/tinytest/

* Add a basic compute_kzg_proof() test
2023-01-30 13:40:12 +00:00
Justin Traglia 60ead4ee49
Add compute_kzg_proof to rust bindings (#91) 2023-01-27 15:14:13 +00:00
George Kadianakis d46544dd2e
General code improvements (#87)
* Better memory management in compute_challenges()

* Forgotten retval check in compute_aggregated_poly_...()

* General niceties around the code
2023-01-26 22:43:17 +00:00
Ramana Kumar 363c7d7593
Improve alignments in docstring comments 2023-01-26 17:13:13 +00:00
Justin Traglia 03b90ef63f
Use Bytes48 for commitments/proofs (#86)
* Start to use bytes48 type

* Update java bindings

* Update variable names

* Update csharp bindings

* Update node.js bindings

* Update python bindings

* Fix mistake in python bindings

* Add new functions

* Fix nit in java bindings

* Update variable names in java bindings

* Compare to point at infinity

* Update bytes_to_bls_field doc

* Add todo

* Do key validation

* Remove bytes_to_g1

* Fix bug & add remark

* Fix memcmp mistake

* Fix nit in nodejs bindings

* Fix another nit

* Update nodejs parameter names

* Remove to_proof() and to_commitment()

* Fix bug
2023-01-26 14:53:30 +00:00
Justin Traglia 0a18868475
Upgrade blst & remove sha256 patch (#85) 2023-01-25 20:07:15 +00:00
Justin Traglia 8907fbcfe2
Expose `compute_kzg_proof` (#80)
* Expose computeKzgProof

* Revert changes to bytes_to/from_bls_field

* Update comments

* Revert changes to bytes_from_bls_field

* Revert change to parameter name

* Add compute_kzg_proof to readme

* Refactor in support of asn's PR

* Clean up a little

* Fix param name doc

* Introduce Bytes32 type

* Update bindings

* Replaces bytes with b to match spec
2023-01-24 18:23:42 +00:00
Justin Traglia d849e626ae
Use downward gotos in g1_lincomb (#83)
* Use downward gotos in g1_lincomb

* Do it asn's way
2023-01-24 18:15:16 +00:00