mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 13:39:25 +00:00
Remove potentially-failing unchecked arithmetic operations for ones which error
In response to 9.13.3. Requires a bump to Rust 1.82 to take advantage of `Option::is_none_or`.
This commit is contained in:
@@ -86,13 +86,16 @@ impl Bulletproof {
|
||||
/// Bulletproofs(+) are logarithmically sized yet linearly timed. Evaluating by their size alone
|
||||
/// accordingly doesn't properly represent the burden of the proof. Monero 'claws back' some of
|
||||
/// the weight lost by using a proof smaller than it is fast to compensate for this.
|
||||
///
|
||||
/// If the amount of outputs specified exceeds the maximum amount of outputs, the result for the
|
||||
/// maximum amount of outputs will be returned.
|
||||
// https://github.com/monero-project/monero/blob/94e67bf96bbc010241f29ada6abc89f49a81759c/
|
||||
// src/cryptonote_basic/cryptonote_format_utils.cpp#L106-L124
|
||||
pub fn calculate_bp_clawback(plus: bool, n_outputs: usize) -> (usize, usize) {
|
||||
#[allow(non_snake_case)]
|
||||
let mut LR_len = 0;
|
||||
let mut n_padded_outputs = 1;
|
||||
while n_padded_outputs < n_outputs {
|
||||
while n_padded_outputs < n_outputs.min(MAX_COMMITMENTS) {
|
||||
LR_len += 1;
|
||||
n_padded_outputs = 1 << LR_len;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user