mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-31 12:31:22 +00:00
ff: Add PrimeField::ReprEndianness associated type
This enables generic code to reliably operate on the bits of an encoded field element, by converting them to and from a known (little) endianness. The BitAnd and Shr bounds on PrimeField are now removed, as users can perform these operations themselves as needed.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use super::multicore::Worker;
|
||||
use bit_vec::{self, BitVec};
|
||||
use ff::{Field, PrimeField, ScalarEngine};
|
||||
use ff::{Endianness, Field, PrimeField, ScalarEngine};
|
||||
use futures::Future;
|
||||
use group::{CurveAffine, CurveProjective};
|
||||
use std::io;
|
||||
@@ -195,8 +195,18 @@ where
|
||||
bases.skip(1)?;
|
||||
}
|
||||
} else {
|
||||
let exp = exp >> skip;
|
||||
let exp = exp & ((1 << c) - 1);
|
||||
let mut exp = exp.into_repr();
|
||||
<<G::Engine as ScalarEngine>::Fr as PrimeField>::ReprEndianness::toggle_little_endian(&mut exp);
|
||||
|
||||
let exp = exp
|
||||
.as_ref()
|
||||
.into_iter()
|
||||
.map(|b| (0..8).map(move |i| (b >> i) & 1u8))
|
||||
.flatten()
|
||||
.skip(skip as usize)
|
||||
.take(c as usize)
|
||||
.enumerate()
|
||||
.fold(0u64, |acc, (i, b)| acc + ((b as u64) << i));
|
||||
|
||||
if exp != 0 {
|
||||
(&mut buckets[(exp - 1) as usize])
|
||||
|
Reference in New Issue
Block a user