mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-17 01:17:36 +00:00
Use ChaCha20 instead of ChaCha12
Despite being slower and only used for blinding values, its still extremely performant. 20 is far more standard and will avoid an eye raise from reviewers.
This commit is contained in:
parent
6093f4ec93
commit
c5256d9b06
3 changed files with 7 additions and 7 deletions
|
@ -5,7 +5,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use rand_core::{RngCore, CryptoRng, SeedableRng};
|
use rand_core::{RngCore, CryptoRng, SeedableRng};
|
||||||
use rand_chacha::ChaCha12Rng;
|
use rand_chacha::ChaCha20Rng;
|
||||||
|
|
||||||
use zeroize::{Zeroize, ZeroizeOnDrop};
|
use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ impl Algorithm<Ed25519> for ClsagMultisig {
|
||||||
// process even if they have access to commitments (specifically, the ring index being signed
|
// process even if they have access to commitments (specifically, the ring index being signed
|
||||||
// for, along with the mask which should not only require knowing the shared keys yet also the
|
// for, along with the mask which should not only require knowing the shared keys yet also the
|
||||||
// input commitment masks)
|
// input commitment masks)
|
||||||
let mut rng = ChaCha12Rng::from_seed(self.transcript.rng_seed(b"decoy_responses"));
|
let mut rng = ChaCha20Rng::from_seed(self.transcript.rng_seed(b"decoy_responses"));
|
||||||
|
|
||||||
self.msg = Some(msg.try_into().expect("CLSAG message should be 32-bytes"));
|
self.msg = Some(msg.try_into().expect("CLSAG message should be 32-bytes"));
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use rand_core::{RngCore, CryptoRng, SeedableRng};
|
use rand_core::{RngCore, CryptoRng, SeedableRng};
|
||||||
use rand_chacha::ChaCha12Rng;
|
use rand_chacha::ChaCha20Rng;
|
||||||
|
|
||||||
use curve25519_dalek::{
|
use curve25519_dalek::{
|
||||||
traits::Identity,
|
traits::Identity,
|
||||||
|
@ -140,7 +140,7 @@ impl SignableTransaction {
|
||||||
let decoys = Decoys::select(
|
let decoys = Decoys::select(
|
||||||
// Using a seeded RNG with a specific height, committed to above, should make these decoys
|
// Using a seeded RNG with a specific height, committed to above, should make these decoys
|
||||||
// committed to. They'll also be committed to later via the TX message as a whole
|
// committed to. They'll also be committed to later via the TX message as a whole
|
||||||
&mut ChaCha12Rng::from_seed(transcript.rng_seed(b"decoys")),
|
&mut ChaCha20Rng::from_seed(transcript.rng_seed(b"decoys")),
|
||||||
rpc,
|
rpc,
|
||||||
self.protocol.ring_len(),
|
self.protocol.ring_len(),
|
||||||
height,
|
height,
|
||||||
|
@ -288,7 +288,7 @@ impl SignMachine<Transaction> for TransactionSignMachine {
|
||||||
sorted_images.sort_by(key_image_sort);
|
sorted_images.sort_by(key_image_sort);
|
||||||
|
|
||||||
self.signable.prepare_transaction(
|
self.signable.prepare_transaction(
|
||||||
&mut ChaCha12Rng::from_seed(self.transcript.rng_seed(b"transaction_keys_bulletproofs")),
|
&mut ChaCha20Rng::from_seed(self.transcript.rng_seed(b"transaction_keys_bulletproofs")),
|
||||||
uniqueness(
|
uniqueness(
|
||||||
&sorted_images
|
&sorted_images
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -312,7 +312,7 @@ impl SignMachine<Transaction> for TransactionSignMachine {
|
||||||
}
|
}
|
||||||
sorted.sort_by(|x, y| key_image_sort(&x.0, &y.0));
|
sorted.sort_by(|x, y| key_image_sort(&x.0, &y.0));
|
||||||
|
|
||||||
let mut rng = ChaCha12Rng::from_seed(self.transcript.rng_seed(b"pseudo_out_masks"));
|
let mut rng = ChaCha20Rng::from_seed(self.transcript.rng_seed(b"pseudo_out_masks"));
|
||||||
let mut sum_pseudo_outs = Scalar::zero();
|
let mut sum_pseudo_outs = Scalar::zero();
|
||||||
while !sorted.is_empty() {
|
while !sorted.is_empty() {
|
||||||
let value = sorted.remove(0);
|
let value = sorted.remove(0);
|
||||||
|
|
|
@ -20,7 +20,7 @@ mod tests;
|
||||||
|
|
||||||
pub(crate) fn challenge<T: Transcript, F: PrimeField>(transcript: &mut T) -> F {
|
pub(crate) fn challenge<T: Transcript, F: PrimeField>(transcript: &mut T) -> F {
|
||||||
// From here, there are three ways to get a scalar under the ff/group API
|
// From here, there are three ways to get a scalar under the ff/group API
|
||||||
// 1: Scalar::random(ChaCha12Rng::from_seed(self.transcript.rng_seed(b"challenge")))
|
// 1: Scalar::random(ChaCha20Rng::from_seed(self.transcript.rng_seed(b"challenge")))
|
||||||
// 2: Grabbing a UInt library to perform reduction by the modulus, then determining endianess
|
// 2: Grabbing a UInt library to perform reduction by the modulus, then determining endianess
|
||||||
// and loading it in
|
// and loading it in
|
||||||
// 3: Iterating over each byte and manually doubling/adding. This is simplest
|
// 3: Iterating over each byte and manually doubling/adding. This is simplest
|
||||||
|
|
Loading…
Reference in a new issue