mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-03 19:53:40 +00:00
Simplifications to some logic.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
This commit is contained in:
parent
775151a67d
commit
1f510016d8
2 changed files with 4 additions and 13 deletions
|
|
@ -9,6 +9,7 @@ use super::{Coeff, LagrangeCoeff, Polynomial};
|
||||||
use crate::arithmetic::{best_fft, best_multiexp, parallelize, Curve, CurveAffine, FieldExt};
|
use crate::arithmetic::{best_fft, best_multiexp, parallelize, Curve, CurveAffine, FieldExt};
|
||||||
|
|
||||||
use ff::{Field, PrimeField};
|
use ff::{Field, PrimeField};
|
||||||
|
use std::convert::TryInto;
|
||||||
use std::ops::{Add, AddAssign, Mul, MulAssign};
|
use std::ops::{Add, AddAssign, Mul, MulAssign};
|
||||||
|
|
||||||
mod msm;
|
mod msm;
|
||||||
|
|
@ -47,9 +48,7 @@ impl<C: CurveAffine> Params<C> {
|
||||||
loop {
|
loop {
|
||||||
let mut hasher = hasher.clone();
|
let mut hasher = hasher.clone();
|
||||||
hasher.update(&(trial.to_le_bytes())[..]);
|
hasher.update(&(trial.to_le_bytes())[..]);
|
||||||
let mut hash = [0u8; 32];
|
let p = C::from_bytes(&hasher.finalize().as_bytes().try_into().unwrap());
|
||||||
hash[..].copy_from_slice(hasher.finalize().as_bytes());
|
|
||||||
let p = C::from_bytes(&hash);
|
|
||||||
if bool::from(p.is_some()) {
|
if bool::from(p.is_some()) {
|
||||||
break p.unwrap();
|
break p.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -271,20 +271,12 @@ pub(crate) fn read_n_points<C: CurveAffine, T: TranscriptRead<C>>(
|
||||||
transcript: &mut T,
|
transcript: &mut T,
|
||||||
n: usize,
|
n: usize,
|
||||||
) -> io::Result<Vec<C>> {
|
) -> io::Result<Vec<C>> {
|
||||||
let mut v = Vec::with_capacity(n);
|
(0..n).map(|_| transcript.read_point()).collect()
|
||||||
for _ in 0..n {
|
|
||||||
v.push(transcript.read_point()?);
|
|
||||||
}
|
|
||||||
Ok(v)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn read_n_scalars<C: CurveAffine, T: TranscriptRead<C>>(
|
pub(crate) fn read_n_scalars<C: CurveAffine, T: TranscriptRead<C>>(
|
||||||
transcript: &mut T,
|
transcript: &mut T,
|
||||||
n: usize,
|
n: usize,
|
||||||
) -> io::Result<Vec<C::Scalar>> {
|
) -> io::Result<Vec<C::Scalar>> {
|
||||||
let mut v = Vec::with_capacity(n);
|
(0..n).map(|_| transcript.read_scalar()).collect()
|
||||||
for _ in 0..n {
|
|
||||||
v.push(transcript.read_scalar()?);
|
|
||||||
}
|
|
||||||
Ok(v)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue