-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da71f78
commit 045ed63
Showing
7 changed files
with
137 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
//! Bulletproofs+ utilities | ||
pub mod generic; | ||
pub(crate) mod nullrng; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2024 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
//! A null random number generator useful for batch verification. | ||
use rand_core::{ | ||
impls::{next_u32_via_fill, next_u64_via_fill}, | ||
CryptoRng, | ||
RngCore, | ||
}; | ||
use zeroize::Zeroize; | ||
|
||
/// This is a null random number generator that exists only for deterministic transcript-based weight generation. | ||
/// It only produces zero. | ||
/// This is DANGEROUS in general; don't use this for any other purpose! | ||
pub(crate) struct NullRng; | ||
|
||
impl RngCore for NullRng { | ||
#[allow(unused_variables)] | ||
fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
dest.zeroize(); | ||
} | ||
|
||
#[allow(unused_variables)] | ||
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { | ||
self.fill_bytes(dest); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn next_u32(&mut self) -> u32 { | ||
next_u32_via_fill(self) | ||
} | ||
|
||
fn next_u64(&mut self) -> u64 { | ||
next_u64_via_fill(self) | ||
} | ||
} | ||
|
||
// This is not actually cryptographically secure! | ||
// We do this so we can use `NullRng` with `TranscriptRng`. | ||
impl CryptoRng for NullRng {} |
Oops, something went wrong.