zcash / halo2

The Halo2 zero-knowledge proving system
https://zcash.github.io/halo2/
Other
716 stars 487 forks source link

Add `no_floating_points` feature flag. #747

Open mpapierski opened 1 year ago

mpapierski commented 1 year ago

We're exploring the usage of halo2 in the context of ACTUS standard implementation and on-chain proof verification. Since our chain, Casper, doesn't support floats we needed these changes to do it. These changes may be useful more broadly since many other blockchains do not support floating points. This contribution should make the halo2_proofs code more universal across different operating systems and architectures.

With this flag turned on, the halo2_proofs crate can be compiled into Wasm, and the resulting binary will not use any floating point operations.

The code to generate the table is here https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cb4b6564b60d0ad65243679f3203fa77 - it's using a binary search to find the lowest argument to the ceil(ln(x)) function in 1..2^64-1 space, that produces the exponent it's looking for. The linked code and this commit contain relevant tests to ensure the lookup table is correct.