mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +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:
@@ -23,6 +23,11 @@ pub(crate) struct InternalBatchVerifier {
|
||||
impl InternalBatchVerifier {
|
||||
#[must_use]
|
||||
fn verify(self, G: EdwardsPoint, H: EdwardsPoint, generators: &Generators) -> bool {
|
||||
/*
|
||||
Technically, this following line can overflow, and joining these `Vec`s _may_ panic if
|
||||
they're individually acceptable lengths yet their sum isn't. This is so negligible, due to
|
||||
the amount of memory required, it's dismissed.
|
||||
*/
|
||||
let capacity = 2 + self.g_bold.len() + self.h_bold.len() + self.other.len();
|
||||
let mut scalars = Vec::with_capacity(capacity);
|
||||
let mut points = Vec::with_capacity(capacity);
|
||||
|
||||
@@ -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