Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add range check sufficiency explanation (resolves #237) #278

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions kzg_prover/src/chips/range/range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ use std::fmt::Debug;
/// Configuration for the Range Check u64 Chip
/// Used to verify that an element lies in the u64 range.
///
/// To prove that the 64-bit balance values would not cause the overflow of the grand sum,
/// let's consider the case at the limit in which we have 2^28 users and all their
/// balances are the maximum possible (namely, 2^64-1):
///
/// >>> 2**28 * (2**64-1)
/// 4951760157141521099328061440
/// >>> n = 4951760157141521099328061440
/// >>> num_bits = n.bit_length()
/// >>> print(num_bits)
/// 92
///
/// The resulting grand sum is only 92 bits. Therefore, we can conclude that the
/// range check of 64 bits on the 2^28 user balances safely removes the risk of overflow
/// in the grand sum calculation.
///
/// # Fields
///
/// * `zs`: Four advice columns - contain the truncated right-shifted values of the element to be checked
Expand Down
Loading