Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions halo2_gadgets/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ and this project adheres to Rust's notion of
a shorthand for `LookupRangeCheck` specialized with `pallas::Base` and `sinsemilla::K`
- `halo2_gadgets::utilities::lookup_range_check::PallasLookupRangeCheckConfig` which is
a shorthand for `LookupRangeCheckConfig` specialized with `pallas::Base` and `sinsemilla::K`
- `halo2_gadgets::ecc::Point::{mul_sign, new_from_constant}`
- `halo2_gadgets::sinsemilla::CommitDomain::{blinding_factor, hash_with_private_init, q_init}`
- `halo2_gadgets::utilities::cond_swap::CondSwapChip::{mux_on_points, mux_on_non_identity_points}`

### Changed
- `halo2_gadgets::utilities::lookup_range_check::witness_short` now takes a generic `Lookup`
instead of directly taking a `LookupRangeCheckConfig<F, K>` reference
- `halo2_gadgets::sinsemilla::merkle::chip::MerkleConfig::cond_swap_config` is now public
- `halo2_gadgets::sinsemilla::chip::SinsemillaChip::configure` has a new input
`init_from_private_point` to enable the evaluation of Sinsemilla hash from a private point.

## [0.3.1] - 2024-12-16
- `halo2_gadgets::poseidon::primitives` is now a re-export of the new `halo2_poseidon`
Expand Down
37 changes: 19 additions & 18 deletions halo2_gadgets/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,14 @@ pub(crate) mod tests {
use group::{prime::PrimeCurveAffine, Curve, Group};
use std::marker::PhantomData;

use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner, Value},
dev::MockProver,
plonk::{Circuit, ConstraintSystem, Error},
};
use lazy_static::lazy_static;
use pasta_curves::pallas;

use super::{
chip::{
find_zs_and_us, BaseFieldElem, EccChip, EccConfig, FixedPoint, FullScalar, ShortScalar,
Expand All @@ -638,13 +646,6 @@ pub(crate) mod tests {
PallasLookupRangeCheck, PallasLookupRangeCheck4_5BConfig, PallasLookupRangeCheckConfig,
},
};
use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner, Value},
dev::MockProver,
plonk::{Circuit, ConstraintSystem, Error},
};
use lazy_static::lazy_static;
use pasta_curves::pallas;

#[derive(Debug, Eq, PartialEq, Clone)]
pub(crate) struct TestFixedBases;
Expand Down Expand Up @@ -772,12 +773,12 @@ pub(crate) mod tests {
type Base = BaseField;
}

struct EccCircuit<Lookup: PallasLookupRangeCheck> {
struct MyEccCircuit<Lookup: PallasLookupRangeCheck> {
test_errors: bool,
_lookup_marker: PhantomData<Lookup>,
}

impl<Lookup: PallasLookupRangeCheck> EccCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> MyEccCircuit<Lookup> {
fn new(test_errors: bool) -> Self {
Self {
test_errors,
Expand All @@ -787,12 +788,12 @@ pub(crate) mod tests {
}

#[allow(non_snake_case)]
impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for EccCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for MyEccCircuit<Lookup> {
type Config = EccConfig<TestFixedBases, Lookup>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
EccCircuit::new(false)
MyEccCircuit::new(false)
}

fn configure(meta: &mut ConstraintSystem<pallas::Base>) -> Self::Config {
Expand Down Expand Up @@ -841,7 +842,7 @@ pub(crate) mod tests {

// Load 10-bit lookup table. In the Action circuit, this will be
// provided by the Sinsemilla chip.
config.lookup_config.load(&mut layouter)?;
config.lookup_config.load_range_check_table(&mut layouter)?;

// Generate a random non-identity point P
let p_val = pallas::Point::random(rand::rngs::OsRng).to_affine(); // P
Expand Down Expand Up @@ -968,14 +969,14 @@ pub(crate) mod tests {
#[test]
fn ecc_chip() {
let k = 13;
let circuit = EccCircuit::<PallasLookupRangeCheckConfig>::new(true);
let circuit = MyEccCircuit::<PallasLookupRangeCheckConfig>::new(true);
let prover = MockProver::run(k, &circuit, vec![]).unwrap();
assert_eq!(prover.verify(), Ok(()))
}

#[test]
fn test_ecc_chip_against_stored_circuit() {
let circuit = EccCircuit::<PallasLookupRangeCheckConfig>::new(false);
let circuit = MyEccCircuit::<PallasLookupRangeCheckConfig>::new(false);
test_against_stored_circuit(circuit, "ecc_chip", 3872);
}

Expand All @@ -988,7 +989,7 @@ pub(crate) mod tests {
root.fill(&WHITE).unwrap();
let root = root.titled("Ecc Chip Layout", ("sans-serif", 60)).unwrap();

let circuit = EccCircuit::<PallasLookupRangeCheckConfig>::new(false);
let circuit = MyEccCircuit::<PallasLookupRangeCheckConfig>::new(false);
halo2_proofs::dev::CircuitLayout::default()
.render(13, &circuit, &root)
.unwrap();
Expand All @@ -997,15 +998,15 @@ pub(crate) mod tests {
#[test]
fn ecc_chip_4_5b() {
let k = 13;
let circuit = EccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(true);
let circuit = MyEccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(true);
let prover = MockProver::run(k, &circuit, vec![]).unwrap();

assert_eq!(prover.verify(), Ok(()))
}

#[test]
fn test_against_stored_ecc_chip_4_5b() {
let circuit = EccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(false);
let circuit = MyEccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(false);
test_against_stored_circuit(circuit, "ecc_chip_4_5b", 3968);
}

Expand All @@ -1018,7 +1019,7 @@ pub(crate) mod tests {
root.fill(&WHITE).unwrap();
let root = root.titled("Ecc Chip Layout", ("sans-serif", 60)).unwrap();

let circuit = EccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(false);
let circuit = MyEccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(false);
halo2_proofs::dev::CircuitLayout::default()
.render(13, &circuit, &root)
.unwrap();
Expand Down
46 changes: 23 additions & 23 deletions halo2_gadgets/src/ecc/chip/mul_fixed/short.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<Fixed: FixedPoints<pallas::Affine>> Config<Fixed> {

/// Multiply the point by sign, using the q_mul_fixed_short gate.
/// Constraints `sign` in {-1, 1}
pub fn assign_scalar_sign(
pub(crate) fn assign_scalar_sign(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the visiability reduction?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To evaluate a variable-base sign-scalar multiplication in Orchard, we use the function mul_sign.
This function assign_scalarmulis used internally withinmul_sign` and is never called outside of Halo2.

&self,
mut layouter: impl Layouter<pallas::Base>,
sign: &AssignedCell<pallas::Base, pallas::Base>,
Expand Down Expand Up @@ -471,7 +471,7 @@ pub mod tests {
}

#[derive(Default)]
struct MagnitudeSignCircuit<Lookup: PallasLookupRangeCheck> {
struct MyMagnitudeSignCircuit<Lookup: PallasLookupRangeCheck> {
magnitude: Value<pallas::Base>,
sign: Value<pallas::Base>,
// For test checking
Expand All @@ -480,17 +480,17 @@ pub mod tests {
}

impl<Lookup: PallasLookupRangeCheck> UtilitiesInstructions<pallas::Base>
for MagnitudeSignCircuit<Lookup>
for MyMagnitudeSignCircuit<Lookup>
{
type Var = AssignedCell<pallas::Base, pallas::Base>;
}

impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for MagnitudeSignCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for MyMagnitudeSignCircuit<Lookup> {
type Config = EccConfig<TestFixedBases, Lookup>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
MagnitudeSignCircuit {
MyMagnitudeSignCircuit {
magnitude: Value::unknown(),
sign: Value::unknown(),
magnitude_error: Value::unknown(),
Expand Down Expand Up @@ -584,41 +584,41 @@ pub mod tests {
}
}

impl<Lookup: PallasLookupRangeCheck> MagnitudeSignCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> MyMagnitudeSignCircuit<Lookup> {
fn test_invalid_magnitude_sign() {
// Magnitude larger than 64 bits should fail
{
let circuits = [
// 2^64
MagnitudeSignCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 64)),
sign: Value::known(pallas::Base::one()),
magnitude_error: Value::known(pallas::Base::from(1 << 1)),
_lookup_marker: PhantomData,
},
// -2^64
MagnitudeSignCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 64)),
sign: Value::known(-pallas::Base::one()),
magnitude_error: Value::known(pallas::Base::from(1 << 1)),
_lookup_marker: PhantomData,
},
// 2^66
MagnitudeSignCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 66)),
sign: Value::known(pallas::Base::one()),
magnitude_error: Value::known(pallas::Base::from(1 << 3)),
_lookup_marker: PhantomData,
},
// -2^66
MagnitudeSignCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 66)),
sign: Value::known(-pallas::Base::one()),
magnitude_error: Value::known(pallas::Base::from(1 << 3)),
_lookup_marker: PhantomData,
},
// 2^254
MagnitudeSignCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 127).square()),
sign: Value::known(pallas::Base::one()),
magnitude_error: Value::known(
Expand All @@ -627,7 +627,7 @@ pub mod tests {
_lookup_marker: PhantomData,
},
// -2^254
MagnitudeSignCircuit::<Lookup> {
MyMagnitudeSignCircuit::<Lookup> {
magnitude: Value::known(pallas::Base::from_u128(1 << 127).square()),
sign: Value::known(-pallas::Base::one()),
magnitude_error: Value::known(
Expand Down Expand Up @@ -682,7 +682,7 @@ pub mod tests {
// Sign that is not +/- 1 should fail
{
let magnitude_u64 = rand::random::<u64>();
let circuit: MagnitudeSignCircuit<Lookup> = MagnitudeSignCircuit {
let circuit: MyMagnitudeSignCircuit<Lookup> = MyMagnitudeSignCircuit {
magnitude: Value::known(pallas::Base::from(magnitude_u64)),
sign: Value::known(pallas::Base::zero()),
magnitude_error: Value::unknown(),
Expand Down Expand Up @@ -744,12 +744,12 @@ pub mod tests {

#[test]
fn invalid_magnitude_sign() {
MagnitudeSignCircuit::<PallasLookupRangeCheckConfig>::test_invalid_magnitude_sign();
MyMagnitudeSignCircuit::<PallasLookupRangeCheckConfig>::test_invalid_magnitude_sign();
}

#[test]
fn invalid_magnitude_sign_4_5b() {
MagnitudeSignCircuit::<PallasLookupRangeCheck4_5BConfig>::test_invalid_magnitude_sign();
MyMagnitudeSignCircuit::<PallasLookupRangeCheck4_5BConfig>::test_invalid_magnitude_sign();
}

pub(crate) fn test_mul_sign<Lookup: PallasLookupRangeCheck>(
Expand Down Expand Up @@ -819,24 +819,24 @@ pub mod tests {
}

#[derive(Default)]
struct MulSignCircuit<Lookup: PallasLookupRangeCheck> {
struct MyMulSignCircuit<Lookup: PallasLookupRangeCheck> {
base: Value<pallas::Affine>,
sign: Value<pallas::Base>,
_lookup_marker: PhantomData<Lookup>,
}

impl<Lookup: PallasLookupRangeCheck> UtilitiesInstructions<pallas::Base>
for MulSignCircuit<Lookup>
for MyMulSignCircuit<Lookup>
{
type Var = AssignedCell<pallas::Base, pallas::Base>;
}

impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for MulSignCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for MyMulSignCircuit<Lookup> {
type Config = EccConfig<TestFixedBases, Lookup>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
MulSignCircuit {
MyMulSignCircuit {
base: Value::unknown(),
sign: Value::unknown(),
_lookup_marker: PhantomData,
Expand Down Expand Up @@ -900,12 +900,12 @@ pub mod tests {
}
}

impl<Lookup: PallasLookupRangeCheck> MulSignCircuit<Lookup> {
impl<Lookup: PallasLookupRangeCheck> MyMulSignCircuit<Lookup> {
fn test_invalid_magnitude_sign() {
// Sign that is not +/- 1 should fail
// Generate a random non-identity point
let point = pallas::Point::random(rand::rngs::OsRng);
let circuit: MulSignCircuit<Lookup> = MulSignCircuit {
let circuit: MyMulSignCircuit<Lookup> = MyMulSignCircuit {
base: Value::known(point.to_affine()),
sign: Value::known(pallas::Base::zero()),
_lookup_marker: PhantomData,
Expand Down Expand Up @@ -954,10 +954,10 @@ pub mod tests {

#[test]
fn invalid_sign_in_mul_sign() {
MulSignCircuit::<PallasLookupRangeCheckConfig>::test_invalid_magnitude_sign();
MyMulSignCircuit::<PallasLookupRangeCheckConfig>::test_invalid_magnitude_sign();
}
#[test]
fn invalid_sign_in_mul_sign_4_5b() {
MulSignCircuit::<PallasLookupRangeCheck4_5BConfig>::test_invalid_magnitude_sign();
MyMulSignCircuit::<PallasLookupRangeCheck4_5BConfig>::test_invalid_magnitude_sign();
}
}
20 changes: 10 additions & 10 deletions halo2_gadgets/src/poseidon/pow5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,31 +238,31 @@
// Load the initial state into this region.
let state = Pow5State::load(&mut region, config, initial_state)?;

let state = (0..config.half_full_rounds).fold(Ok(state), |res, r| {
res.and_then(|state| state.full_round(&mut region, config, r, r))
})?;

Check warning on line 243 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

usage of `Iterator::fold` on a type that implements `Try`

warning: usage of `Iterator::fold` on a type that implements `Try` --> halo2_gadgets/src/poseidon/pow5.rs:241:58 | 241 | let state = (0..config.half_full_rounds).fold(Ok(state), |res, r| { | __________________________________________________________^ 242 | | res.and_then(|state| state.full_round(&mut region, config, r, r)) 243 | | })?; | |__________________^ help: use `try_fold` instead: `try_fold(state, |res, r| ...)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold = note: `-W clippy::manual-try-fold` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::manual_try_fold)]`

Check warning on line 243 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

usage of `Iterator::fold` on a type that implements `Try`

warning: usage of `Iterator::fold` on a type that implements `Try` --> halo2_gadgets/src/poseidon/pow5.rs:241:58 | 241 | let state = (0..config.half_full_rounds).fold(Ok(state), |res, r| { | __________________________________________________________^ 242 | | res.and_then(|state| state.full_round(&mut region, config, r, r)) 243 | | })?; | |__________________^ help: use `try_fold` instead: `try_fold(state, |res, r| ...)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold = note: `-W clippy::manual-try-fold` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::manual_try_fold)]`

let state = (0..config.half_partial_rounds).fold(Ok(state), |res, r| {
res.and_then(|state| {
state.partial_round(
&mut region,
config,
config.half_full_rounds + 2 * r,
config.half_full_rounds + r,
)
})
})?;

Check warning on line 254 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

usage of `Iterator::fold` on a type that implements `Try`

warning: usage of `Iterator::fold` on a type that implements `Try` --> halo2_gadgets/src/poseidon/pow5.rs:245:61 | 245 | let state = (0..config.half_partial_rounds).fold(Ok(state), |res, r| { | _____________________________________________________________^ 246 | | res.and_then(|state| { 247 | | state.partial_round( 248 | | &mut region, ... | 253 | | }) 254 | | })?; | |__________________^ help: use `try_fold` instead: `try_fold(state, |res, r| ...)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold

let state = (0..config.half_full_rounds).fold(Ok(state), |res, r| {
res.and_then(|state| {
state.full_round(
&mut region,
config,
config.half_full_rounds + 2 * config.half_partial_rounds + r,
config.half_full_rounds + config.half_partial_rounds + r,
)
})
})?;

Check warning on line 265 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

usage of `Iterator::fold` on a type that implements `Try`

warning: usage of `Iterator::fold` on a type that implements `Try` --> halo2_gadgets/src/poseidon/pow5.rs:256:58 | 256 | let state = (0..config.half_full_rounds).fold(Ok(state), |res, r| { | __________________________________________________________^ 257 | | res.and_then(|state| { 258 | | state.full_round( 259 | | &mut region, ... | 264 | | }) 265 | | })?; | |__________________^ help: use `try_fold` instead: `try_fold(state, |res, r| ...)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold

Check warning on line 265 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

usage of `Iterator::fold` on a type that implements `Try`

warning: usage of `Iterator::fold` on a type that implements `Try` --> halo2_gadgets/src/poseidon/pow5.rs:256:58 | 256 | let state = (0..config.half_full_rounds).fold(Ok(state), |res, r| { | __________________________________________________________^ 257 | | res.and_then(|state| { 258 | | state.full_round( 259 | | &mut region, ... | 264 | | }) 265 | | })?; | |__________________^ help: use `try_fold` instead: `try_fold(state, |res, r| ...)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold

Ok(state.0)
},
Expand All @@ -289,7 +289,7 @@
let mut state = Vec::with_capacity(WIDTH);
let mut load_state_word = |i: usize, value: F| -> Result<_, Error> {
let var = region.assign_advice_from_constant(
|| format!("state_{}", i),

Check warning on line 292 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:292:28 | 292 | || format!("state_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 292 - || format!("state_{}", i), 292 + || format!("state_{i}"), |

Check warning on line 292 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:292:28 | 292 | || format!("state_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 292 - || format!("state_{}", i), 292 + || format!("state_{i}"), |
config.state[i],
0,
value,
Expand Down Expand Up @@ -328,7 +328,7 @@
initial_state[i]
.0
.copy_advice(
|| format!("load state_{}", i),

Check warning on line 331 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:331:32 | 331 | ... || format!("load state_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 331 - || format!("load state_{}", i), 331 + || format!("load state_{i}"), |

Check warning on line 331 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:331:32 | 331 | ... || format!("load state_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 331 - || format!("load state_{}", i), 331 + || format!("load state_{i}"), |
&mut region,
config.state[i],
0,
Expand All @@ -347,7 +347,7 @@
let value = Value::known(*padding_value);
let cell = region
.assign_fixed(
|| format!("load pad_{}", i),

Check warning on line 350 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:350:40 | 350 | ... || format!("load pad_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 350 - || format!("load pad_{}", i), 350 + || format!("load pad_{i}"), |

Check warning on line 350 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:350:40 | 350 | ... || format!("load pad_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 350 - || format!("load pad_{}", i), 350 + || format!("load pad_{i}"), |
config.rc_b[i],
1,
|| value,
Expand All @@ -358,7 +358,7 @@
_ => panic!("Input is not padded"),
};
let var = region.assign_advice(
|| format!("load input_{}", i),

Check warning on line 361 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:361:28 | 361 | || format!("load input_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 361 - || format!("load input_{}", i), 361 + || format!("load input_{i}"), |

Check warning on line 361 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:361:28 | 361 | || format!("load input_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 361 - || format!("load input_{}", i), 361 + || format!("load input_{i}"), |
config.state[i],
1,
|| value,
Expand All @@ -385,7 +385,7 @@
.unwrap_or_else(|| Value::known(F::ZERO));
region
.assign_advice(
|| format!("load output_{}", i),

Check warning on line 388 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:388:32 | 388 | ... || format!("load output_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 388 - || format!("load output_{}", i), 388 + || format!("load output_{i}"), |

Check warning on line 388 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:388:32 | 388 | ... || format!("load output_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 388 - || format!("load output_{}", i), 388 + || format!("load output_{i}"), |
config.state[i],
2,
|| value,
Expand Down Expand Up @@ -448,7 +448,7 @@
.value()
.map(|v| *v + config.round_constants[round][idx])
});
let r: Value<Vec<F>> = q.map(|q| q.map(|q| q.pow(&config.alpha))).collect();

Check warning on line 451 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> halo2_gadgets/src/poseidon/pow5.rs:451:62 | 451 | let r: Value<Vec<F>> = q.map(|q| q.map(|q| q.pow(&config.alpha))).collect(); | ^^^^^^^^^^^^^ help: change this to: `config.alpha` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 451 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> halo2_gadgets/src/poseidon/pow5.rs:451:62 | 451 | let r: Value<Vec<F>> = q.map(|q| q.map(|q| q.pow(&config.alpha))).collect(); | ^^^^^^^^^^^^^ help: change this to: `config.alpha` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
let m = &config.m_reg;
let state = m.iter().map(|m_i| {
r.as_ref().map(|r| {
Expand All @@ -474,7 +474,7 @@
let p: Value<Vec<_>> = self.0.iter().map(|word| word.0.value().cloned()).collect();

let r: Value<Vec<_>> = p.map(|p| {
let r_0 = (p[0] + config.round_constants[round][0]).pow(&config.alpha);

Check warning on line 477 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> halo2_gadgets/src/poseidon/pow5.rs:477:73 | 477 | let r_0 = (p[0] + config.round_constants[round][0]).pow(&config.alpha); | ^^^^^^^^^^^^^ help: change this to: `config.alpha` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 477 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> halo2_gadgets/src/poseidon/pow5.rs:477:73 | 477 | let r_0 = (p[0] + config.round_constants[round][0]).pow(&config.alpha); | ^^^^^^^^^^^^^ help: change this to: `config.alpha` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
let r_i = p[1..]
.iter()
.enumerate()
Expand All @@ -483,7 +483,7 @@
});

region.assign_advice(
|| format!("round_{} partial_sbox", round),

Check warning on line 486 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:486:20 | 486 | || format!("round_{} partial_sbox", round), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 486 - || format!("round_{} partial_sbox", round), 486 + || format!("round_{round} partial_sbox"), |

Check warning on line 486 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:486:20 | 486 | || format!("round_{} partial_sbox", round), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 486 - || format!("round_{} partial_sbox", round), 486 + || format!("round_{round} partial_sbox"), |
config.partial_sbox,
offset,
|| r.as_ref().map(|r| r[0]),
Expand Down Expand Up @@ -514,7 +514,7 @@
}

let r_mid: Value<Vec<_>> = p_mid.map(|p| {
let r_0 = (p[0] + config.round_constants[round + 1][0]).pow(&config.alpha);

Check warning on line 517 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> halo2_gadgets/src/poseidon/pow5.rs:517:77 | 517 | let r_0 = (p[0] + config.round_constants[round + 1][0]).pow(&config.alpha); | ^^^^^^^^^^^^^ help: change this to: `config.alpha` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args

Check warning on line 517 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> halo2_gadgets/src/poseidon/pow5.rs:517:77 | 517 | let r_0 = (p[0] + config.round_constants[round + 1][0]).pow(&config.alpha); | ^^^^^^^^^^^^^ help: change this to: `config.alpha` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
let r_i = p[1..]
.iter()
.enumerate()
Expand Down Expand Up @@ -545,7 +545,7 @@
let load_state_word = |i: usize| {
initial_state[i]
.0
.copy_advice(|| format!("load state_{}", i), region, config.state[i], 0)

Check warning on line 548 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:548:33 | 548 | .copy_advice(|| format!("load state_{}", i), region, config.state[i], 0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 548 - .copy_advice(|| format!("load state_{}", i), region, config.state[i], 0) 548 + .copy_advice(|| format!("load state_{i}"), region, config.state[i], 0) |

Check warning on line 548 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:548:33 | 548 | .copy_advice(|| format!("load state_{}", i), region, config.state[i], 0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 548 - .copy_advice(|| format!("load state_{}", i), region, config.state[i], 0) 548 + .copy_advice(|| format!("load state_{i}"), region, config.state[i], 0) |
.map(StateWord)
};

Expand All @@ -567,7 +567,7 @@
// Load the round constants.
let mut load_round_constant = |i: usize| {
region.assign_fixed(
|| format!("round_{} rc_{}", round, i),

Check warning on line 570 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:570:20 | 570 | || format!("round_{} rc_{}", round, i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 570 - || format!("round_{} rc_{}", round, i), 570 + || format!("round_{round} rc_{i}"), |

Check warning on line 570 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:570:20 | 570 | || format!("round_{} rc_{}", round, i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 570 - || format!("round_{} rc_{}", round, i), 570 + || format!("round_{round} rc_{i}"), |
config.rc_a[i],
offset,
|| Value::known(config.round_constants[round][i]),
Expand All @@ -583,7 +583,7 @@
let next_state_word = |i: usize| {
let value = next_state[i];
let var = region.assign_advice(
|| format!("round_{} state_{}", next_round, i),

Check warning on line 586 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:586:20 | 586 | || format!("round_{} state_{}", next_round, i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 586 - || format!("round_{} state_{}", next_round, i), 586 + || format!("round_{next_round} state_{i}"), |

Check warning on line 586 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:586:20 | 586 | || format!("round_{} state_{}", next_round, i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 586 - || format!("round_{} state_{}", next_round, i), 586 + || format!("round_{next_round} state_{i}"), |
config.state[i],
offset + 1,
|| value,
Expand Down Expand Up @@ -618,18 +618,18 @@
use std::convert::TryInto;
use std::marker::PhantomData;

struct PermuteCircuit<S: Spec<Fp, WIDTH, RATE>, const WIDTH: usize, const RATE: usize>(
struct MyPermuteCircuit<S: Spec<Fp, WIDTH, RATE>, const WIDTH: usize, const RATE: usize>(
PhantomData<S>,
);

impl<S: Spec<Fp, WIDTH, RATE>, const WIDTH: usize, const RATE: usize> Circuit<Fp>
for PermuteCircuit<S, WIDTH, RATE>
for MyPermuteCircuit<S, WIDTH, RATE>
{
type Config = Pow5Config<Fp, WIDTH, RATE>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
PermuteCircuit::<S, WIDTH, RATE>(PhantomData)
MyPermuteCircuit::<S, WIDTH, RATE>(PhantomData)
}

fn configure(meta: &mut ConstraintSystem<Fp>) -> Pow5Config<Fp, WIDTH, RATE> {
Expand Down Expand Up @@ -659,7 +659,7 @@
let state_word = |i: usize| {
let value = Value::known(Fp::from(i as u64));
let var = region.assign_advice(
|| format!("load state_{}", i),

Check warning on line 662 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:662:32 | 662 | ... || format!("load state_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 662 - || format!("load state_{}", i), 662 + || format!("load state_{i}"), |
config.state[i],
0,
|| value,
Expand Down Expand Up @@ -698,7 +698,7 @@
|mut region| {
let mut final_state_word = |i: usize| {
let var = region.assign_advice(
|| format!("load final_state_{}", i),

Check warning on line 701 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:701:32 | 701 | ... || format!("load final_state_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 701 - || format!("load final_state_{}", i), 701 + || format!("load final_state_{i}"), |
config.state[i],
0,
|| Value::known(expected_final_state[i]),
Expand All @@ -719,12 +719,12 @@
#[test]
fn poseidon_permute() {
let k = 6;
let circuit = PermuteCircuit::<OrchardNullifier, 3, 2>(PhantomData);
let circuit = MyPermuteCircuit::<OrchardNullifier, 3, 2>(PhantomData);
let prover = MockProver::run(k, &circuit, vec![]).unwrap();
assert_eq!(prover.verify(), Ok(()))
}

struct HashCircuit<
struct MyHashCircuit<
S: Spec<Fp, WIDTH, RATE>,
const WIDTH: usize,
const RATE: usize,
Expand All @@ -738,7 +738,7 @@
}

impl<S: Spec<Fp, WIDTH, RATE>, const WIDTH: usize, const RATE: usize, const L: usize>
Circuit<Fp> for HashCircuit<S, WIDTH, RATE, L>
Circuit<Fp> for MyHashCircuit<S, WIDTH, RATE, L>
{
type Config = Pow5Config<Fp, WIDTH, RATE>;
type FloorPlanner = SimpleFloorPlanner;
Expand Down Expand Up @@ -782,7 +782,7 @@
let message_word = |i: usize| {
let value = self.message.map(|message_vals| message_vals[i]);
region.assign_advice(
|| format!("load message_{}", i),

Check warning on line 785 in halo2_gadgets/src/poseidon/pow5.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

variables can be used directly in the `format!` string

warning: variables can be used directly in the `format!` string --> halo2_gadgets/src/poseidon/pow5.rs:785:32 | 785 | ... || format!("load message_{}", i), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 785 - || format!("load message_{}", i), 785 + || format!("load message_{i}"), |
config.state[i],
0,
|| value,
Expand Down Expand Up @@ -824,7 +824,7 @@
poseidon::Hash::<_, OrchardNullifier, ConstantLength<2>, 3, 2>::init().hash(message);

let k = 6;
let circuit = HashCircuit::<OrchardNullifier, 3, 2, 2> {
let circuit = MyHashCircuit::<OrchardNullifier, 3, 2, 2> {
message: Value::known(message),
output: Value::known(output),
_spec: PhantomData,
Expand All @@ -842,7 +842,7 @@
poseidon::Hash::<_, OrchardNullifier, ConstantLength<3>, 3, 2>::init().hash(message);

let k = 7;
let circuit = HashCircuit::<OrchardNullifier, 3, 2, 3> {
let circuit = MyHashCircuit::<OrchardNullifier, 3, 2, 3> {
message: Value::known(message),
output: Value::known(output),
_spec: PhantomData,
Expand Down Expand Up @@ -884,7 +884,7 @@
.hash(message);

let k = 6;
let circuit = HashCircuit::<OrchardNullifier, 3, 2, 2> {
let circuit = MyHashCircuit::<OrchardNullifier, 3, 2, 2> {
message: Value::known(message),
output: Value::known(output),
_spec: PhantomData,
Expand All @@ -905,7 +905,7 @@
.titled("Poseidon Chip Layout", ("sans-serif", 60))
.unwrap();

let circuit = HashCircuit::<OrchardNullifier, 3, 2, 2> {
let circuit = MyHashCircuit::<OrchardNullifier, 3, 2, 2> {
message: Value::unknown(),
output: Value::unknown(),
_spec: PhantomData,
Expand Down
Loading
Loading