mirror of https://github.com/zcash/halo2.git
Merge pull request #678 from nuttycom/fix_clippy_lints
Fix beta and nightly clippy complaints
This commit is contained in:
commit
6ae9f77e04
|
@ -12,7 +12,7 @@ In the case of Zordle, this code is contained in [wasm.rs](https://github.com/na
|
|||
|
||||
### Prover
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
#[wasm_bindgen]
|
||||
pub async fn prove_play(final_word: String, words_js: JsValue, params_ser: JsValue) -> JsValue {
|
||||
// Steps:
|
||||
|
@ -34,7 +34,7 @@ The output is a `Vec<u8>` converted to a `JSValue` using Serde. This is later pa
|
|||
|
||||
### Verifier
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
#[wasm_bindgen]
|
||||
pub fn verify_play(final_word: String, proof_js: JsValue, diffs_u64_js: JsValue, params_ser: JsValue) -> bool {
|
||||
// Steps:
|
||||
|
@ -51,7 +51,7 @@ Similar to the prover, we take in input and output a boolean true/false indicati
|
|||
|
||||
Additionally, both the prover and verifier functions input `params_ser`, a serialised form of the public parameters of the polynomial commitment scheme. These are passed in as input (instead of being regenerated in prove/verify functions) as a performance optimisation since these are constant based only on the circuit's value of `K`. We can store these seperately on a static web server and pass them in as input to the WASM. To generate the binary serialised form of these (seperately outside the WASM functions), you can run something like:
|
||||
|
||||
```rust
|
||||
```rust,ignore
|
||||
fn write_params(K: u32) {
|
||||
let mut params_file = File::create("params.bin").unwrap();
|
||||
let params: Params<EqAffine> = Params::new(K);
|
||||
|
@ -124,4 +124,4 @@ Often, you'll run into issues with your Rust code and see that the WASM executio
|
|||
|
||||
## Credits
|
||||
|
||||
This guide was written by [Nalin](https://twitter.com/nibnalin). Thanks additionally to [Uma](https://twitter.com/pumatheuma) and [Blaine](https://twitter.com/BlaineBublitz) for significant work on figuring out these steps. Feel free to reach out to me if you have trouble with any of these steps.
|
||||
This guide was written by [Nalin](https://twitter.com/nibnalin). Thanks additionally to [Uma](https://twitter.com/pumatheuma) and [Blaine](https://twitter.com/BlaineBublitz) for significant work on figuring out these steps. Feel free to reach out to me if you have trouble with any of these steps.
|
||||
|
|
|
@ -131,7 +131,7 @@ impl Spec<Fp, 3, 2> for MySpec<3, 2> {
|
|||
}
|
||||
|
||||
fn sbox(val: Fp) -> Fp {
|
||||
val.pow_vartime(&[5])
|
||||
val.pow_vartime([5])
|
||||
}
|
||||
|
||||
fn secure_mds() -> usize {
|
||||
|
@ -153,7 +153,7 @@ impl Spec<Fp, 9, 8> for MySpec<9, 8> {
|
|||
}
|
||||
|
||||
fn sbox(val: Fp) -> Fp {
|
||||
val.pow_vartime(&[5])
|
||||
val.pow_vartime([5])
|
||||
}
|
||||
|
||||
fn secure_mds() -> usize {
|
||||
|
@ -175,7 +175,7 @@ impl Spec<Fp, 12, 11> for MySpec<12, 11> {
|
|||
}
|
||||
|
||||
fn sbox(val: Fp) -> Fp {
|
||||
val.pow_vartime(&[5])
|
||||
val.pow_vartime([5])
|
||||
}
|
||||
|
||||
fn secure_mds() -> usize {
|
||||
|
|
|
@ -79,18 +79,18 @@ fn bench(name: &str, k: u32, c: &mut Criterion) {
|
|||
|
||||
// Initialize the polynomial commitment parameters
|
||||
let params_path = Path::new("./benches/sha256_assets/sha256_params");
|
||||
if File::open(¶ms_path).is_err() {
|
||||
if File::open(params_path).is_err() {
|
||||
let params: Params<EqAffine> = Params::new(k);
|
||||
let mut buf = Vec::new();
|
||||
|
||||
params.write(&mut buf).expect("Failed to write params");
|
||||
let mut file = File::create(¶ms_path).expect("Failed to create sha256_params");
|
||||
let mut file = File::create(params_path).expect("Failed to create sha256_params");
|
||||
|
||||
file.write_all(&buf[..])
|
||||
.expect("Failed to write params to file");
|
||||
}
|
||||
|
||||
let params_fs = File::open(¶ms_path).expect("couldn't load sha256_params");
|
||||
let params_fs = File::open(params_path).expect("couldn't load sha256_params");
|
||||
let params: Params<EqAffine> =
|
||||
Params::read::<_>(&mut BufReader::new(params_fs)).expect("Failed to read params");
|
||||
|
||||
|
@ -117,16 +117,16 @@ fn bench(name: &str, k: u32, c: &mut Criterion) {
|
|||
|
||||
// Create a proof
|
||||
let proof_path = Path::new("./benches/sha256_assets/sha256_proof");
|
||||
if File::open(&proof_path).is_err() {
|
||||
if File::open(proof_path).is_err() {
|
||||
let mut transcript = Blake2bWrite::<_, _, Challenge255<_>>::init(vec![]);
|
||||
create_proof(¶ms, &pk, &[circuit], &[], OsRng, &mut transcript)
|
||||
.expect("proof generation should not fail");
|
||||
let proof: Vec<u8> = transcript.finalize();
|
||||
let mut file = File::create(&proof_path).expect("Failed to create sha256_proof");
|
||||
let mut file = File::create(proof_path).expect("Failed to create sha256_proof");
|
||||
file.write_all(&proof[..]).expect("Failed to write proof");
|
||||
}
|
||||
|
||||
let mut proof_fs = File::open(&proof_path).expect("couldn't load sha256_proof");
|
||||
let mut proof_fs = File::open(proof_path).expect("couldn't load sha256_proof");
|
||||
let mut proof = Vec::<u8>::new();
|
||||
proof_fs
|
||||
.read_to_end(&mut proof)
|
||||
|
|
|
@ -437,14 +437,14 @@ impl<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq> Point<C,
|
|||
/// The affine short Weierstrass x-coordinate of a point on a specific elliptic curve.
|
||||
#[derive(Debug)]
|
||||
pub struct X<C: CurveAffine, EccChip: EccInstructions<C>> {
|
||||
chip: EccChip,
|
||||
inner: EccChip::X,
|
||||
}
|
||||
|
||||
impl<C: CurveAffine, EccChip: EccInstructions<C>> X<C, EccChip> {
|
||||
/// Wraps the given x-coordinate (obtained directly from an instruction) in a gadget.
|
||||
pub fn from_inner(chip: EccChip, inner: EccChip::X) -> Self {
|
||||
X { chip, inner }
|
||||
let _ = chip; // unused
|
||||
X { inner }
|
||||
}
|
||||
|
||||
/// Returns the inner x-coordinate.
|
||||
|
|
|
@ -493,7 +493,7 @@ impl ScalarFixed {
|
|||
.by_vals()
|
||||
.take(FIXED_BASE_WINDOW_SIZE)
|
||||
.rev()
|
||||
.fold(0, |acc, b| 2 * acc + if b { 1 } else { 0 })
|
||||
.fold(0, |acc, b| 2 * acc + usize::from(b))
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
|
|
|
@ -33,7 +33,6 @@ pub struct Pow5Config<F: Field, const WIDTH: usize, const RATE: usize> {
|
|||
alpha: [u64; 4],
|
||||
round_constants: Vec<[F; WIDTH]>,
|
||||
m_reg: Mds<F, WIDTH>,
|
||||
m_inv: Mds<F, WIDTH>,
|
||||
}
|
||||
|
||||
/// A Poseidon chip using an $x^5$ S-Box.
|
||||
|
@ -200,7 +199,6 @@ impl<F: Field, const WIDTH: usize, const RATE: usize> Pow5Chip<F, WIDTH, RATE> {
|
|||
alpha,
|
||||
round_constants,
|
||||
m_reg,
|
||||
m_inv,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ impl Spec<Fp, 3, 2> for P128Pow5T3 {
|
|||
}
|
||||
|
||||
fn sbox(val: Fp) -> Fp {
|
||||
val.pow_vartime(&[5])
|
||||
val.pow_vartime([5])
|
||||
}
|
||||
|
||||
fn secure_mds() -> usize {
|
||||
|
@ -48,7 +48,7 @@ impl Spec<Fq, 3, 2> for P128Pow5T3 {
|
|||
}
|
||||
|
||||
fn sbox(val: Fq) -> Fq {
|
||||
val.pow_vartime(&[5])
|
||||
val.pow_vartime([5])
|
||||
}
|
||||
|
||||
fn secure_mds() -> usize {
|
||||
|
@ -101,7 +101,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn sbox(val: F) -> F {
|
||||
val.pow_vartime(&[5])
|
||||
val.pow_vartime([5])
|
||||
}
|
||||
|
||||
fn secure_mds() -> usize {
|
||||
|
|
|
@ -111,7 +111,7 @@ pub fn get_round_row(round_idx: RoundIdx) -> usize {
|
|||
RoundIdx::Init => 0,
|
||||
RoundIdx::Main(MainRoundIdx(idx)) => {
|
||||
assert!(idx < 64);
|
||||
(idx as usize) * SUBREGION_MAIN_WORD
|
||||
idx * SUBREGION_MAIN_WORD
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -783,7 +783,7 @@ impl CompressionConfig {
|
|||
|| "h_prime_carry",
|
||||
a_9,
|
||||
row + 1,
|
||||
|| h_prime_carry.map(|value| pallas::Base::from(value as u64)),
|
||||
|| h_prime_carry.map(pallas::Base::from),
|
||||
)?;
|
||||
|
||||
let h_prime: Value<[bool; 32]> = h_prime.map(|w| i2lebsp(w.into()));
|
||||
|
|
|
@ -40,20 +40,17 @@ pub fn get_word_row(word_idx: usize) -> usize {
|
|||
if word_idx == 0 {
|
||||
0
|
||||
} else if (1..=13).contains(&word_idx) {
|
||||
SUBREGION_0_ROWS + SUBREGION_1_WORD * (word_idx - 1) as usize
|
||||
SUBREGION_0_ROWS + SUBREGION_1_WORD * (word_idx - 1)
|
||||
} else if (14..=48).contains(&word_idx) {
|
||||
SUBREGION_0_ROWS + SUBREGION_1_ROWS + SUBREGION_2_WORD * (word_idx - 14) + 1
|
||||
} else if (49..=61).contains(&word_idx) {
|
||||
SUBREGION_0_ROWS
|
||||
+ SUBREGION_1_ROWS
|
||||
+ SUBREGION_2_ROWS
|
||||
+ SUBREGION_3_WORD * (word_idx - 49) as usize
|
||||
SUBREGION_0_ROWS + SUBREGION_1_ROWS + SUBREGION_2_ROWS + SUBREGION_3_WORD * (word_idx - 49)
|
||||
} else {
|
||||
SUBREGION_0_ROWS
|
||||
+ SUBREGION_1_ROWS
|
||||
+ SUBREGION_2_ROWS
|
||||
+ SUBREGION_3_ROWS
|
||||
+ DECOMPOSE_0_ROWS * (word_idx - 62) as usize
|
||||
+ DECOMPOSE_0_ROWS * (word_idx - 62)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ pub struct Subregion1Word {
|
|||
index: usize,
|
||||
a: AssignedBits<3>,
|
||||
b: AssignedBits<4>,
|
||||
c: AssignedBits<11>,
|
||||
d: AssignedBits<14>,
|
||||
_c: AssignedBits<11>,
|
||||
_d: AssignedBits<14>,
|
||||
spread_c: AssignedBits<22>,
|
||||
spread_d: AssignedBits<28>,
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ impl MessageScheduleConfig {
|
|||
index,
|
||||
a,
|
||||
b,
|
||||
c: spread_c.dense,
|
||||
d: spread_d.dense,
|
||||
_c: spread_c.dense,
|
||||
_d: spread_d.dense,
|
||||
spread_c: spread_c.spread,
|
||||
spread_d: spread_d.spread,
|
||||
})
|
||||
|
|
|
@ -15,10 +15,10 @@ pub struct Subregion2Word {
|
|||
a: AssignedBits<3>,
|
||||
b: AssignedBits<4>,
|
||||
c: AssignedBits<3>,
|
||||
d: AssignedBits<7>,
|
||||
_d: AssignedBits<7>,
|
||||
e: AssignedBits<1>,
|
||||
f: AssignedBits<1>,
|
||||
g: AssignedBits<13>,
|
||||
_g: AssignedBits<13>,
|
||||
spread_d: AssignedBits<14>,
|
||||
spread_g: AssignedBits<26>,
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ impl MessageScheduleConfig {
|
|||
|| format!("carry_{}", new_word_idx),
|
||||
a_9,
|
||||
get_word_row(new_word_idx - 16) + 1,
|
||||
|| carry.map(|carry| pallas::Base::from(carry as u64)),
|
||||
|| carry.map(pallas::Base::from),
|
||||
)?;
|
||||
let (word, halves) = self.assign_word_and_halves(region, word, new_word_idx)?;
|
||||
w.push(MessageWord(word));
|
||||
|
@ -342,10 +342,10 @@ impl MessageScheduleConfig {
|
|||
a,
|
||||
b: spread_b.dense,
|
||||
c,
|
||||
d: spread_d.dense,
|
||||
_d: spread_d.dense,
|
||||
e,
|
||||
f,
|
||||
g: spread_g.dense,
|
||||
_g: spread_g.dense,
|
||||
spread_d: spread_d.spread,
|
||||
spread_g: spread_g.spread,
|
||||
})
|
||||
|
|
|
@ -177,7 +177,7 @@ impl MessageScheduleConfig {
|
|||
|| format!("carry_{}", new_word_idx),
|
||||
a_9,
|
||||
get_word_row(new_word_idx - 16) + 1,
|
||||
|| carry.map(|carry| pallas::Base::from(carry as u64)),
|
||||
|| carry.map(pallas::Base::from),
|
||||
)?;
|
||||
let (word, halves) = self.assign_word_and_halves(region, word, new_word_idx)?;
|
||||
w.push(MessageWord(word));
|
||||
|
|
|
@ -69,7 +69,7 @@ impl<const DENSE: usize, const SPREAD: usize> SpreadWord<DENSE, SPREAD> {
|
|||
/// A variable stored in advice columns corresponding to a row of [`SpreadTableConfig`].
|
||||
#[derive(Clone, Debug)]
|
||||
pub(super) struct SpreadVar<const DENSE: usize, const SPREAD: usize> {
|
||||
pub tag: Value<u8>,
|
||||
pub _tag: Value<u8>,
|
||||
pub dense: AssignedBits<DENSE>,
|
||||
pub spread: AssignedBits<SPREAD>,
|
||||
}
|
||||
|
@ -98,7 +98,11 @@ impl<const DENSE: usize, const SPREAD: usize> SpreadVar<DENSE, SPREAD> {
|
|||
let spread =
|
||||
AssignedBits::<SPREAD>::assign_bits(region, || "spread", cols.spread, row, spread_val)?;
|
||||
|
||||
Ok(SpreadVar { tag, dense, spread })
|
||||
Ok(SpreadVar {
|
||||
_tag: tag,
|
||||
dense,
|
||||
spread,
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn without_lookup(
|
||||
|
@ -129,7 +133,11 @@ impl<const DENSE: usize, const SPREAD: usize> SpreadVar<DENSE, SPREAD> {
|
|||
spread_val,
|
||||
)?;
|
||||
|
||||
Ok(SpreadVar { tag, dense, spread })
|
||||
Ok(SpreadVar {
|
||||
_tag: tag,
|
||||
dense,
|
||||
spread,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ pub fn sum_with_carry(words: Vec<(Value<u16>, Value<u16>)>) -> (Value<u32>, Valu
|
|||
sum_lo.zip(sum_hi).map(|(lo, hi)| lo + (1 << 16) * hi)
|
||||
};
|
||||
|
||||
let carry = sum.map(|sum| (sum >> 32) as u64);
|
||||
let carry = sum.map(|sum| sum >> 32);
|
||||
let sum = sum.map(|sum| sum as u32);
|
||||
|
||||
(sum, carry)
|
||||
|
|
|
@ -166,7 +166,6 @@ pub struct MessagePiece<C: CurveAffine, SinsemillaChip, const K: usize, const MA
|
|||
where
|
||||
SinsemillaChip: SinsemillaInstructions<C, K, MAX_WORDS> + Clone + Debug + Eq,
|
||||
{
|
||||
chip: SinsemillaChip,
|
||||
inner: SinsemillaChip::MessagePiece,
|
||||
}
|
||||
|
||||
|
@ -199,7 +198,7 @@ where
|
|||
// Each message piece must have at most `floor(C::Base::CAPACITY / K)` words.
|
||||
// This ensures that the all-ones bitstring is canonical in the field.
|
||||
let piece_max_num_words = C::Base::CAPACITY as usize / K;
|
||||
assert!(num_words <= piece_max_num_words as usize);
|
||||
assert!(num_words <= piece_max_num_words);
|
||||
|
||||
// Closure to parse a bitstring (little-endian) into a base field element.
|
||||
let to_base_field = |bits: &[Value<bool>]| -> Value<C::Base> {
|
||||
|
@ -227,7 +226,7 @@ where
|
|||
num_words: usize,
|
||||
) -> Result<Self, Error> {
|
||||
let inner = chip.witness_message_piece(layouter, field_elem, num_words)?;
|
||||
Ok(Self { chip, inner })
|
||||
Ok(Self { inner })
|
||||
}
|
||||
|
||||
/// Constructs a `MessagePiece` by concatenating a sequence of [`RangeConstrained`]
|
||||
|
|
|
@ -6,6 +6,15 @@ and this project adheres to Rust's notion of
|
|||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
- The following structs now derive the `Eq` trait:
|
||||
- `halo2_proofs::dev`:
|
||||
- `failure::FailureLocation`
|
||||
- `failure::VerifyFailure`
|
||||
- `metadata::Gate`
|
||||
- `metadata::Constraint`
|
||||
- `metadata::Region`
|
||||
- `halo2_proofs::poly::Rotation`
|
||||
|
||||
### Added
|
||||
- `halo2_proofs::arithmetic::FftGroup`
|
||||
- `halo2_proofs::circuit::layouter`:
|
||||
|
|
|
@ -195,7 +195,7 @@ pub fn best_fft<Scalar: Field, G: FftGroup<Scalar>>(a: &mut [G], omega: Scalar,
|
|||
|
||||
let threads = multicore::current_num_threads();
|
||||
let log_threads = log2_floor(threads);
|
||||
let n = a.len() as usize;
|
||||
let n = a.len();
|
||||
assert_eq!(n, 1 << log_n);
|
||||
|
||||
for k in 0..n {
|
||||
|
@ -206,7 +206,7 @@ pub fn best_fft<Scalar: Field, G: FftGroup<Scalar>>(a: &mut [G], omega: Scalar,
|
|||
}
|
||||
|
||||
// precompute twiddle factors
|
||||
let twiddles: Vec<_> = (0..(n / 2) as usize)
|
||||
let twiddles: Vec<_> = (0..(n / 2))
|
||||
.scan(Scalar::one(), |w, _| {
|
||||
let tw = *w;
|
||||
*w *= ω
|
||||
|
@ -216,7 +216,7 @@ pub fn best_fft<Scalar: Field, G: FftGroup<Scalar>>(a: &mut [G], omega: Scalar,
|
|||
|
||||
if log_n <= log_threads {
|
||||
let mut chunk = 2_usize;
|
||||
let mut twiddle_chunk = (n / 2) as usize;
|
||||
let mut twiddle_chunk = n / 2;
|
||||
for _ in 0..log_n {
|
||||
a.chunks_mut(chunk).for_each(|coeffs| {
|
||||
let (left, right) = coeffs.split_at_mut(chunk / 2);
|
||||
|
@ -339,9 +339,9 @@ where
|
|||
pub fn parallelize<T: Send, F: Fn(&mut [T], usize) + Send + Sync + Clone>(v: &mut [T], f: F) {
|
||||
let n = v.len();
|
||||
let num_threads = multicore::current_num_threads();
|
||||
let mut chunk = (n as usize) / num_threads;
|
||||
let mut chunk = n / num_threads;
|
||||
if chunk < num_threads {
|
||||
chunk = n as usize;
|
||||
chunk = n;
|
||||
}
|
||||
|
||||
multicore::scope(|scope| {
|
||||
|
@ -374,7 +374,7 @@ pub fn lagrange_interpolate<F: Field>(points: &[F], evals: &[F]) -> Vec<F> {
|
|||
assert_eq!(points.len(), evals.len());
|
||||
if points.len() == 1 {
|
||||
// Constant polynomial
|
||||
return vec![evals[0]];
|
||||
vec![evals[0]]
|
||||
} else {
|
||||
let mut denoms = Vec::with_capacity(points.len());
|
||||
for (j, x_j) in points.iter().enumerate() {
|
||||
|
|
|
@ -81,8 +81,8 @@ impl FloorPlanner for V1 {
|
|||
|
||||
// - Determine how many rows our planned circuit will require.
|
||||
let first_unassigned_row = column_allocations
|
||||
.iter()
|
||||
.map(|(_, a)| a.unbounded_interval_start())
|
||||
.values()
|
||||
.map(|a| a.unbounded_interval_start())
|
||||
.max()
|
||||
.unwrap_or(0);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ use crate::{
|
|||
};
|
||||
|
||||
/// Measures a circuit to determine its costs, and explain what contributes to them.
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub struct CircuitCost<G: PrimeGroup, ConcreteCircuit: Circuit<G::Scalar>> {
|
||||
/// Power-of-2 bound on the number of rows in the circuit.
|
||||
|
@ -54,6 +55,7 @@ pub struct CircuitCost<G: PrimeGroup, ConcreteCircuit: Circuit<G::Scalar>> {
|
|||
}
|
||||
|
||||
/// Region implementation used by Layout
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct LayoutRegion {
|
||||
/// The name of the region. Not required to be unique.
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::{
|
|||
mod emitter;
|
||||
|
||||
/// The location within the circuit at which a particular [`VerifyFailure`] occurred.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum FailureLocation {
|
||||
/// A location inside a region.
|
||||
InRegion {
|
||||
|
@ -100,16 +100,14 @@ impl FailureLocation {
|
|||
})
|
||||
.map(|(r_i, r)| FailureLocation::InRegion {
|
||||
region: (r_i, r.name.clone()).into(),
|
||||
offset: failure_row as usize - r.rows.unwrap().0 as usize,
|
||||
})
|
||||
.unwrap_or_else(|| FailureLocation::OutsideRegion {
|
||||
row: failure_row as usize,
|
||||
offset: failure_row - r.rows.unwrap().0,
|
||||
})
|
||||
.unwrap_or_else(|| FailureLocation::OutsideRegion { row: failure_row })
|
||||
}
|
||||
}
|
||||
|
||||
/// The reasons why a particular circuit is not satisfied.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum VerifyFailure {
|
||||
/// A cell used in an active gate was not assigned to.
|
||||
CellNotAssigned {
|
||||
|
|
|
@ -178,7 +178,7 @@ impl CircuitLayout {
|
|||
|
||||
root.draw(&Rectangle::new(
|
||||
[(0, 0), (total_columns, view_bottom)],
|
||||
&BLACK,
|
||||
BLACK,
|
||||
))?;
|
||||
|
||||
let draw_region = |root: &DrawingArea<_, _>, top_left, bottom_right| {
|
||||
|
@ -194,7 +194,7 @@ impl CircuitLayout {
|
|||
[top_left, bottom_right],
|
||||
ShapeStyle::from(&GREEN.mix(0.2)).filled(),
|
||||
))?;
|
||||
root.draw(&Rectangle::new([top_left, bottom_right], &BLACK))?;
|
||||
root.draw(&Rectangle::new([top_left, bottom_right], BLACK))?;
|
||||
Ok(())
|
||||
};
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ impl fmt::Display for VirtualCell {
|
|||
}
|
||||
|
||||
/// Metadata about a configured gate within a circuit.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Gate {
|
||||
/// The index of the active gate. These indices are assigned in the order in which
|
||||
/// `ConstraintSystem::create_gate` is called during `Circuit::configure`.
|
||||
|
@ -106,7 +106,7 @@ impl From<(usize, &'static str)> for Gate {
|
|||
}
|
||||
|
||||
/// Metadata about a configured constraint within a circuit.
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Constraint {
|
||||
/// The gate containing the constraint.
|
||||
pub(super) gate: Gate,
|
||||
|
@ -143,7 +143,7 @@ impl From<(Gate, usize, &'static str)> for Constraint {
|
|||
}
|
||||
|
||||
/// Metadata about an assigned region within a circuit.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Region {
|
||||
/// The index of the region. These indices are assigned in the order in which
|
||||
/// `Layouter::assign_region` is called during `Circuit::synthesize`.
|
||||
|
|
|
@ -612,7 +612,7 @@ mod proptests {
|
|||
// Ensure that:
|
||||
// - we have at least one value to apply unary operators to.
|
||||
// - we can apply every binary operator pairwise sequentially.
|
||||
cmp::max(if num_unary > 0 { 1 } else { 0 }, num_binary + 1)),
|
||||
cmp::max(usize::from(num_unary > 0), num_binary + 1)),
|
||||
operations in arb_operators(num_unary, num_binary).prop_shuffle(),
|
||||
) -> (Vec<Assigned<Fp>>, Vec<Operator>) {
|
||||
(values, operations)
|
||||
|
|
|
@ -70,33 +70,30 @@ where
|
|||
|
||||
// All provided selectors of degree 0 are assumed to be either concrete
|
||||
// selectors or do not appear in a gate. Let's address these first.
|
||||
selectors = selectors
|
||||
.into_iter()
|
||||
.filter(|selector| {
|
||||
if selector.max_degree == 0 {
|
||||
// This is a complex selector, or a selector that does not appear in any
|
||||
// gate constraint.
|
||||
let expression = allocate_fixed_column();
|
||||
selectors.retain(|selector| {
|
||||
if selector.max_degree == 0 {
|
||||
// This is a complex selector, or a selector that does not appear in any
|
||||
// gate constraint.
|
||||
let expression = allocate_fixed_column();
|
||||
|
||||
let combination_assignment = selector
|
||||
.activations
|
||||
.iter()
|
||||
.map(|b| if *b { F::one() } else { F::zero() })
|
||||
.collect::<Vec<_>>();
|
||||
let combination_index = combination_assignments.len();
|
||||
combination_assignments.push(combination_assignment);
|
||||
selector_assignments.push(SelectorAssignment {
|
||||
selector: selector.selector,
|
||||
combination_index,
|
||||
expression,
|
||||
});
|
||||
let combination_assignment = selector
|
||||
.activations
|
||||
.iter()
|
||||
.map(|b| if *b { F::one() } else { F::zero() })
|
||||
.collect::<Vec<_>>();
|
||||
let combination_index = combination_assignments.len();
|
||||
combination_assignments.push(combination_assignment);
|
||||
selector_assignments.push(SelectorAssignment {
|
||||
selector: selector.selector,
|
||||
combination_index,
|
||||
expression,
|
||||
});
|
||||
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
|
||||
// All of the remaining `selectors` are simple. Let's try to combine them.
|
||||
// First, we compute the exclusion matrix that has (j, k) = true if selector
|
||||
|
|
|
@ -613,7 +613,7 @@ fn permute_expression_pair<C: CurveAffine, R: RngCore>(
|
|||
// Populate permuted table at unfilled rows with leftover table elements
|
||||
for (coeff, count) in leftover_table_map.iter() {
|
||||
for _ in 0..*count {
|
||||
permuted_table_coeffs[repeated_input_rows.pop().unwrap() as usize] = *coeff;
|
||||
permuted_table_coeffs[repeated_input_rows.pop().unwrap()] = *coeff;
|
||||
}
|
||||
}
|
||||
assert!(repeated_input_rows.is_empty());
|
||||
|
|
|
@ -128,7 +128,7 @@ impl Argument {
|
|||
Any::Instance => instance,
|
||||
};
|
||||
parallelize(&mut modified_values, |modified_values, start| {
|
||||
let mut deltaomega = deltaomega * &omega.pow_vartime(&[start as u64, 0, 0, 0]);
|
||||
let mut deltaomega = deltaomega * &omega.pow_vartime([start as u64, 0, 0, 0]);
|
||||
for (modified_values, value) in modified_values
|
||||
.iter_mut()
|
||||
.zip(values[column.index()][start..].iter())
|
||||
|
@ -292,7 +292,7 @@ impl<C: CurveAffine, Ev: Copy + Send + Sync> Committed<C, Ev> {
|
|||
|
||||
let mut right = poly::Ast::from(set.permutation_product_coset);
|
||||
let mut current_delta = *beta
|
||||
* &(C::Scalar::DELTA.pow_vartime(&[(chunk_index * chunk_len) as u64]));
|
||||
* &(C::Scalar::DELTA.pow_vartime([(chunk_index * chunk_len) as u64]));
|
||||
for values in columns.iter().map(|&column| match column.column_type() {
|
||||
Any::Advice => &advice_cosets[column.index()],
|
||||
Any::Fixed => &fixed_cosets[column.index()],
|
||||
|
|
|
@ -179,7 +179,7 @@ impl<C: CurveAffine> Evaluated<C> {
|
|||
|
||||
let mut right = set.permutation_product_eval;
|
||||
let mut current_delta = (*beta * &*x)
|
||||
* &(C::Scalar::DELTA.pow_vartime(&[(chunk_index * chunk_len) as u64]));
|
||||
* &(C::Scalar::DELTA.pow_vartime([(chunk_index * chunk_len) as u64]));
|
||||
for eval in columns.iter().map(|&column| match column.column_type() {
|
||||
Any::Advice => {
|
||||
advice_evals[vk.cs.get_any_query_index(column, Rotation::cur())]
|
||||
|
|
|
@ -596,7 +596,7 @@ pub fn create_proof<
|
|||
)?;
|
||||
|
||||
let x: ChallengeX<_> = transcript.squeeze_challenge_scalar();
|
||||
let xn = x.pow(&[params.n as u64, 0, 0, 0]);
|
||||
let xn = x.pow(&[params.n, 0, 0, 0]);
|
||||
|
||||
// Compute and hash instance evals for each circuit instance
|
||||
for instance in instance.iter() {
|
||||
|
|
|
@ -203,7 +203,7 @@ pub fn verify_proof<
|
|||
// commitments open to the correct values.
|
||||
let vanishing = {
|
||||
// x^n
|
||||
let xn = x.pow(&[params.n as u64, 0, 0, 0]);
|
||||
let xn = x.pow(&[params.n, 0, 0, 0]);
|
||||
|
||||
let blinding_factors = vk.cs.blinding_factors();
|
||||
let l_evals = vk
|
||||
|
|
|
@ -304,7 +304,7 @@ impl<F: Field, B: Basis> Mul<F> for Polynomial<F, B> {
|
|||
/// Describes the relative rotation of a vector. Negative numbers represent
|
||||
/// reverse (leftmost) rotations and positive numbers represent forward (rightmost)
|
||||
/// rotations. Zero represents no rotation.
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Rotation(pub i32);
|
||||
|
||||
impl Rotation {
|
||||
|
|
|
@ -82,7 +82,7 @@ impl<C: CurveAffine> Params<C> {
|
|||
}
|
||||
let mut g_lagrange_projective = g_projective;
|
||||
best_fft(&mut g_lagrange_projective, alpha_inv, k);
|
||||
let minv = C::Scalar::TWO_INV.pow_vartime(&[k as u64, 0, 0, 0]);
|
||||
let minv = C::Scalar::TWO_INV.pow_vartime([k as u64, 0, 0, 0]);
|
||||
parallelize(&mut g_lagrange_projective, |g, _| {
|
||||
for g in g.iter_mut() {
|
||||
*g *= minv;
|
||||
|
|
|
@ -85,8 +85,8 @@ impl<F: FieldExt> EvaluationDomain<F> {
|
|||
{
|
||||
// Compute the evaluations of t(X) = X^n - 1 in the coset evaluation domain.
|
||||
// We don't have to compute all of them, because it will repeat.
|
||||
let orig = F::ZETA.pow_vartime(&[n as u64, 0, 0, 0]);
|
||||
let step = extended_omega.pow_vartime(&[n as u64, 0, 0, 0]);
|
||||
let orig = F::ZETA.pow_vartime([n, 0, 0, 0]);
|
||||
let step = extended_omega.pow_vartime([n, 0, 0, 0]);
|
||||
let mut cur = orig;
|
||||
loop {
|
||||
t_evaluations.push(cur);
|
||||
|
@ -404,11 +404,11 @@ impl<F: FieldExt> EvaluationDomain<F> {
|
|||
pub fn rotate_omega(&self, value: F, rotation: Rotation) -> F {
|
||||
let mut point = value;
|
||||
if rotation.0 >= 0 {
|
||||
point *= &self.get_omega().pow_vartime(&[rotation.0 as u64]);
|
||||
point *= &self.get_omega().pow_vartime([rotation.0 as u64]);
|
||||
} else {
|
||||
point *= &self
|
||||
.get_omega_inv()
|
||||
.pow_vartime(&[(rotation.0 as i64).unsigned_abs()]);
|
||||
.pow_vartime([(rotation.0 as i64).unsigned_abs()]);
|
||||
}
|
||||
point
|
||||
}
|
||||
|
|
|
@ -540,7 +540,7 @@ impl BasisOps for LagrangeCoeff {
|
|||
let omega = domain.get_omega();
|
||||
let start = chunk_size * chunk_index;
|
||||
(0..cmp::min(chunk_size, poly_len - start))
|
||||
.scan(omega.pow_vartime(&[start as u64]) * scalar, |acc, _| {
|
||||
.scan(omega.pow_vartime([start as u64]) * scalar, |acc, _| {
|
||||
let ret = *acc;
|
||||
*acc *= omega;
|
||||
Some(ret)
|
||||
|
@ -585,7 +585,7 @@ impl BasisOps for ExtendedLagrangeCoeff {
|
|||
let start = chunk_size * chunk_index;
|
||||
(0..cmp::min(chunk_size, poly_len - start))
|
||||
.scan(
|
||||
omega.pow_vartime(&[start as u64]) * F::ZETA * scalar,
|
||||
omega.pow_vartime([start as u64]) * F::ZETA * scalar,
|
||||
|acc, _| {
|
||||
let ret = *acc;
|
||||
*acc *= omega;
|
||||
|
|
Loading…
Reference in New Issue