Skip to content

Commit

Permalink
Add range check sufficiency explanation in the chip docs (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxkzmn authored Mar 26, 2024
1 parent bbd2a5f commit c7ddf7c
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit c7ddf7c

Please sign in to comment.