Skip to content

Commit

Permalink
Use sinsemilla_chip as a parameter of MerkleConfig instead of sinsemi…
Browse files Browse the repository at this point in the history
…lla_config
  • Loading branch information
dmidem committed Apr 25, 2024
1 parent f165fb1 commit 8454123
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 138 deletions.
15 changes: 12 additions & 3 deletions halo2_gadgets/src/sinsemilla/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,27 @@ where
}
}

/*
trait SinsemillaArgs {
type Hash: HashDomains<pallas::Affine>,
type Fixed: FixedPoints<pallas::Affine>,
type Commit: CommitDomains<pallas::Affine, Fixed, Hash>,
type Lookup: DefaultLookupRangeCheck,
}
*/

/// A chip that implements 10-bit Sinsemilla using a lookup table and 5 advice columns.
///
/// [Chip description](https://zcash.github.io/halo2/design/gadgets/sinsemilla.html#plonk--halo-2-constraints).
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct SinsemillaChip<Hash, Commit, Fixed, LookupRangeCheckConfig>
pub struct SinsemillaChip<Hash, Commit, Fixed, Lookup>
where
Hash: HashDomains<pallas::Affine>,
Fixed: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, Fixed, Hash>,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
Lookup: DefaultLookupRangeCheck,
{
config: SinsemillaConfig<Hash, Commit, Fixed, LookupRangeCheckConfig>,
config: SinsemillaConfig<Hash, Commit, Fixed, Lookup>,
}

impl<Hash, Commit, Fixed, LookupRangeCheckConfig> Chip<pallas::Base>
Expand Down
202 changes: 85 additions & 117 deletions halo2_gadgets/src/sinsemilla/merkle/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ use super::MerkleInstructions;

use crate::{
sinsemilla::{primitives as sinsemilla, MessagePiece},
utilities::{lookup_range_check::DefaultLookupRangeCheck, RangeConstrained},
utilities::RangeConstrained,
{
ecc::FixedPoints,
sinsemilla::{
chip::{SinsemillaChip, SinsemillaConfig},
CommitDomains, HashDomains, SinsemillaInstructions,
},
sinsemilla::SinsemillaInstructions,
utilities::{
cond_swap::{CondSwapChip, CondSwapConfig, CondSwapInstructions},
UtilitiesInstructions,
Expand All @@ -28,17 +24,15 @@ use group::ff::PrimeField;

/// Configuration for the `MerkleChip` implementation.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MerkleConfig<Hash, Commit, Fixed, LookupRangeCheckConfig>
pub struct MerkleConfig<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
Fixed: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, Fixed, Hash>,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
advices: [Column<Advice>; 5],
q_decompose: Selector,
pub(crate) cond_swap_config: CondSwapConfig,
pub(crate) sinsemilla_config: SinsemillaConfig<Hash, Commit, Fixed, LookupRangeCheckConfig>,
sinsemilla_chip: SinsemillaChip,
}

/// Chip implementing `MerkleInstructions`.
Expand All @@ -52,25 +46,20 @@ where
/// This chip does **NOT** constrain `left⋆` and `right⋆` to be canonical encodings of
/// `left` and `right`.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MerkleChip<Hash, Commit, Fixed, LookupRangeCheckConfig>
pub struct MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
Fixed: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, Fixed, Hash>,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
config: MerkleConfig<Hash, Commit, Fixed, LookupRangeCheckConfig>,
config: MerkleConfig<SinsemillaChip>,
}

impl<Hash, Commit, Fixed, LookupRangeCheckConfig> Chip<pallas::Base>
for MerkleChip<Hash, Commit, Fixed, LookupRangeCheckConfig>
impl<SinsemillaChip> Chip<pallas::Base> for MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
Fixed: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, Fixed, Hash>,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
type Config = MerkleConfig<Hash, Commit, Fixed, LookupRangeCheckConfig>;
type Config = MerkleConfig<SinsemillaChip>;

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

`SinsemillaChip` doesn't implement `std::fmt::Debug`

error[E0277]: `SinsemillaChip` doesn't implement `std::fmt::Debug` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:62:19 | 62 | type Config = MerkleConfig<SinsemillaChip>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SinsemillaChip` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | note: required for `sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>` to implement `std::fmt::Debug` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:26:17 | 26 | #[derive(Clone, Debug, PartialEq, Eq)] | ^^^^^ unsatisfied trait bound introduced in this `derive` macro note: required by a bound in `halo2_proofs::circuit::Chip::Config` --> /home/runner/work/halo2/halo2/halo2_proofs/src/circuit.rs:33:18 | 33 | type Config: fmt::Debug + Clone; | ^^^^^^^^^^ required by this bound in `Chip::Config` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | 60 | + SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }> + std::fmt::Debug, | +++++++++++++++++

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

the trait bound `SinsemillaChip: std::clone::Clone` is not satisfied

error[E0277]: the trait bound `SinsemillaChip: std::clone::Clone` is not satisfied --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:62:19 | 62 | type Config = MerkleConfig<SinsemillaChip>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `SinsemillaChip`, which is required by `sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>: std::clone::Clone` | note: required for `sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>` to implement `std::clone::Clone` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:26:10 | 26 | #[derive(Clone, Debug, PartialEq, Eq)] | ^^^^^ unsatisfied trait bound introduced in this `derive` macro note: required by a bound in `halo2_proofs::circuit::Chip::Config` --> /home/runner/work/halo2/halo2/halo2_proofs/src/circuit.rs:33:31 | 33 | type Config: fmt::Debug + Clone; | ^^^^^ required by this bound in `Chip::Config` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | 60 | + SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }> + std::clone::Clone, | +++++++++++++++++++

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

`SinsemillaChip` doesn't implement `std::fmt::Debug`

error[E0277]: `SinsemillaChip` doesn't implement `std::fmt::Debug` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:62:19 | 62 | type Config = MerkleConfig<SinsemillaChip>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SinsemillaChip` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` | note: required for `sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>` to implement `std::fmt::Debug` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:26:17 | 26 | #[derive(Clone, Debug, PartialEq, Eq)] | ^^^^^ unsatisfied trait bound introduced in this `derive` macro note: required by a bound in `halo2_proofs::circuit::Chip::Config` --> /home/runner/work/halo2/halo2/halo2_proofs/src/circuit.rs:33:18 | 33 | type Config: fmt::Debug + Clone; | ^^^^^^^^^^ required by this bound in `Chip::Config` = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | 60 | + SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }> + std::fmt::Debug, | +++++++++++++++++

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

the trait bound `SinsemillaChip: std::clone::Clone` is not satisfied

error[E0277]: the trait bound `SinsemillaChip: std::clone::Clone` is not satisfied --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:62:19 | 62 | type Config = MerkleConfig<SinsemillaChip>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `SinsemillaChip`, which is required by `sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>: std::clone::Clone` | note: required for `sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>` to implement `std::clone::Clone` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:26:10 | 26 | #[derive(Clone, Debug, PartialEq, Eq)] | ^^^^^ unsatisfied trait bound introduced in this `derive` macro note: required by a bound in `halo2_proofs::circuit::Chip::Config` --> /home/runner/work/halo2/halo2/halo2_proofs/src/circuit.rs:33:31 | 33 | type Config: fmt::Debug + Clone; | ^^^^^ required by this bound in `Chip::Config` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | 60 | + SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }> + std::clone::Clone, | +++++++++++++++++++

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

the trait bound `SinsemillaChip: Clone` is not satisfied

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

`SinsemillaChip` doesn't implement `Debug`

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Book tests

the trait bound `SinsemillaChip: Clone` is not satisfied

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Book tests

`SinsemillaChip` doesn't implement `Debug`

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

the trait bound `SinsemillaChip: std::clone::Clone` is not satisfied

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

`SinsemillaChip` doesn't implement `std::fmt::Debug`

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

the trait bound `SinsemillaChip: Clone` is not satisfied

Check failure on line 62 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

`SinsemillaChip` doesn't implement `Debug`
type Loaded = ();

fn config(&self) -> &Self::Config {
Expand All @@ -82,20 +71,18 @@ where
}
}

impl<Hash, Commit, F, LookupRangeCheckConfig> MerkleChip<Hash, Commit, F, LookupRangeCheckConfig>
impl<SinsemillaChip> MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash>,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
/// Configures the [`MerkleChip`].
pub fn configure(
meta: &mut ConstraintSystem<pallas::Base>,
sinsemilla_config: SinsemillaConfig<Hash, Commit, F, LookupRangeCheckConfig>,
) -> MerkleConfig<Hash, Commit, F, LookupRangeCheckConfig> {
sinsemilla_chip: SinsemillaChip,
) -> MerkleConfig<SinsemillaChip> {
// All five advice columns are equality-enabled by SinsemillaConfig.
let advices = sinsemilla_config.advices();
let advices = sinsemilla_chip.config().advices();

Check failure on line 85 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no method named `advices` found for reference `&<SinsemillaChip as halo2_proofs::circuit::Chip<pasta_curves::Fp>>::Config` in the current scope

error[E0599]: no method named `advices` found for reference `&<SinsemillaChip as halo2_proofs::circuit::Chip<pasta_curves::Fp>>::Config` in the current scope --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:85:48 | 85 | let advices = sinsemilla_chip.config().advices(); | ^^^^^^^ method not found in `&<SinsemillaChip as Chip<Fp>>::Config`

Check failure on line 85 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no method named `advices` found for reference `&<SinsemillaChip as halo2_proofs::circuit::Chip<pasta_curves::Fp>>::Config` in the current scope

error[E0599]: no method named `advices` found for reference `&<SinsemillaChip as halo2_proofs::circuit::Chip<pasta_curves::Fp>>::Config` in the current scope --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:85:48 | 85 | let advices = sinsemilla_chip.config().advices(); | ^^^^^^^ method not found in `&<SinsemillaChip as Chip<Fp>>::Config`

Check failure on line 85 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

no method named `advices` found for reference `&<SinsemillaChip as Chip<pasta_curves::Fp>>::Config` in the current scope

Check failure on line 85 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Book tests

no method named `advices` found for reference `&<SinsemillaChip as Chip<pasta_curves::Fp>>::Config` in the current scope

Check failure on line 85 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

no method named `advices` found for reference `&<SinsemillaChip as Chip<pasta_curves::Fp>>::Config` in the current scope
let cond_swap_config = CondSwapChip::configure(meta, advices);

// This selector enables the decomposition gate.
Expand Down Expand Up @@ -191,24 +178,22 @@ where
advices,
q_decompose,
cond_swap_config,
sinsemilla_config,
sinsemilla_chip,
}
}

/// Constructs a [`MerkleChip`] given a [`MerkleConfig`].
pub fn construct(config: MerkleConfig<Hash, Commit, F, LookupRangeCheckConfig>) -> Self {
pub fn construct(config: MerkleConfig<SinsemillaChip>) -> Self {
MerkleChip { config }
}
}

impl<Hash, Commit, F, LookupRangeCheckConfig, const MERKLE_DEPTH: usize>
impl<SinsemillaChip, const MERKLE_DEPTH: usize>
MerkleInstructions<pallas::Affine, MERKLE_DEPTH, { sinsemilla::K }, { sinsemilla::C }>
for MerkleChip<Hash, Commit, F, LookupRangeCheckConfig>
for MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine> + Eq,
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash> + Eq,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
#[allow(non_snake_case)]
fn hash_layer(
Expand Down Expand Up @@ -421,24 +406,18 @@ where
}
}

impl<Hash, Commit, F, LookupRangeCheckConfig> UtilitiesInstructions<pallas::Base>
for MerkleChip<Hash, Commit, F, LookupRangeCheckConfig>
impl<SinsemillaChip> UtilitiesInstructions<pallas::Base> for MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash>,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
type Var = AssignedCell<pallas::Base, pallas::Base>;
}

impl<Hash, Commit, F, LookupRangeCheckConfig> CondSwapInstructions<pallas::Base>
for MerkleChip<Hash, Commit, F, LookupRangeCheckConfig>
impl<SinsemillaChip> CondSwapInstructions<pallas::Base> for MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash>,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
#[allow(clippy::type_complexity)]
fn swap(
Expand All @@ -453,71 +432,61 @@ where
}
}

impl<Hash, Commit, F, LookupRangeCheckConfig>
SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>
for MerkleChip<Hash, Commit, F, LookupRangeCheckConfig>
// FIXME: do we need to constraint SinsemillaChipt with Chip<pallas::Base>?
impl<SinsemillaChip> SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>
for MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash>,
LookupRangeCheckConfig: DefaultLookupRangeCheck,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
type CellValue =
<SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::CellValue;

type Message =
<SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::Message;
type MessagePiece =
<SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::MessagePiece;
type RunningSum =
<SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::RunningSum;

type X = <SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
type CellValue = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::CellValue;

type Message = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::Message;
type MessagePiece = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::MessagePiece;
type RunningSum = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::RunningSum;

type X = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::X;
type NonIdentityPoint =
<SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::NonIdentityPoint;
type FixedPoints =
<SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::FixedPoints;

type HashDomains =
<SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::HashDomains;
type CommitDomains =
<SinsemillaChip<Hash, Commit, F, LookupRangeCheckConfig> as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::CommitDomains;
type NonIdentityPoint = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::NonIdentityPoint;
type FixedPoints = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::FixedPoints;

type HashDomains = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::HashDomains;
type CommitDomains = <SinsemillaChip as SinsemillaInstructions<
pallas::Affine,
{ sinsemilla::K },
{ sinsemilla::C },
>>::CommitDomains;

fn witness_message_piece(
&self,
Expand All @@ -526,8 +495,8 @@ where
num_words: usize,
) -> Result<Self::MessagePiece, Error> {
let config = self.config().sinsemilla_config.clone();

Check failure on line 497 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no field `sinsemilla_config` on type `&sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>`

error[E0609]: no field `sinsemilla_config` on type `&sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:497:36 | 497 | let config = self.config().sinsemilla_config.clone(); | ^^^^^^^^^^^^^^^^^ unknown field | help: a field with a similar name exists | 497 | let config = self.config().sinsemilla_chip.clone(); | ~~~~~~~~~~~~~~~

Check failure on line 497 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no field `sinsemilla_config` on type `&sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>`

error[E0609]: no field `sinsemilla_config` on type `&sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:497:36 | 497 | let config = self.config().sinsemilla_config.clone(); | ^^^^^^^^^^^^^^^^^ unknown field | help: a field with a similar name exists | 497 | let config = self.config().sinsemilla_chip.clone(); | ~~~~~~~~~~~~~~~
let chip = SinsemillaChip::<Hash, Commit, F, LookupRangeCheckConfig>::construct(config);
chip.witness_message_piece(layouter, value, num_words)
self.sinsemilla_chip

Check failure on line 498 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no field `sinsemilla_chip` on type `&sinsemilla::merkle::chip::MerkleChip<SinsemillaChip>`

error[E0609]: no field `sinsemilla_chip` on type `&sinsemilla::merkle::chip::MerkleChip<SinsemillaChip>` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:498:14 | 498 | self.sinsemilla_chip | ^^^^^^^^^^^^^^^ unknown field | help: one of the expressions' fields has a field of the same name | 498 | self.config.sinsemilla_chip | +++++++

Check failure on line 498 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no field `sinsemilla_chip` on type `&sinsemilla::merkle::chip::MerkleChip<SinsemillaChip>`

error[E0609]: no field `sinsemilla_chip` on type `&sinsemilla::merkle::chip::MerkleChip<SinsemillaChip>` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:498:14 | 498 | self.sinsemilla_chip | ^^^^^^^^^^^^^^^ unknown field | help: one of the expressions' fields has a field of the same name | 498 | self.config.sinsemilla_chip | +++++++
.witness_message_piece(layouter, value, num_words)
}

#[allow(non_snake_case)]
Expand All @@ -539,11 +508,10 @@ where
message: Self::Message,
) -> Result<(Self::NonIdentityPoint, Vec<Vec<Self::CellValue>>), Error> {

Check failure on line 509 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

method `hash_to_point` has an incompatible type for trait

error[E0053]: method `hash_to_point` has an incompatible type for trait --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:509:10 | 509 | ) -> Result<(Self::NonIdentityPoint, Vec<Vec<Self::CellValue>>), Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | expected associated type, found `Vec<<... as SinsemillaInstructions<..., 10, 253>>::CellValue>` | help: change the output type to match the trait: `std::result::Result<(<SinsemillaChip as sinsemilla::SinsemillaInstructions<pasta_curves::EpAffine, 10, 253>>::NonIdentityPoint, std::vec::Vec<<SinsemillaChip as sinsemilla::SinsemillaInstructions<pasta_curves::EpAffine, 10, 253>>::RunningSum>), halo2_proofs::plonk::Error>` | note: type in trait --> halo2_gadgets/src/sinsemilla.rs:89:10 | 89 | ) -> Result<(Self::NonIdentityPoint, Vec<Self::RunningSum>), Error>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(&sinsemilla::merkle::chip::MerkleChip<_>, _, pasta_curves::EpAffine, _) -> std::result::Result<(_, std::vec::Vec<<SinsemillaChip as sinsemilla::SinsemillaInstructions<pasta_curves::EpAffine, 10, 253>>::RunningSum>), _>` found signature `fn(&sinsemilla::merkle::chip::MerkleChip<_>, _, pasta_curves::EpAffine, _) -> std::result::Result<(_, std::vec::Vec<std::vec::Vec<<SinsemillaChip as sinsemilla::SinsemillaInstructions<pasta_curves::EpAffine, 10, 253>>::CellValue>>), _>`

Check failure on line 509 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

method `hash_to_point` has an incompatible type for trait

error[E0053]: method `hash_to_point` has an incompatible type for trait --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:509:10 | 509 | ) -> Result<(Self::NonIdentityPoint, Vec<Vec<Self::CellValue>>), Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | expected associated type, found `Vec<<... as SinsemillaInstructions<..., 10, 253>>::CellValue>` | help: change the output type to match the trait: `std::result::Result<(<SinsemillaChip as sinsemilla::SinsemillaInstructions<pasta_curves::EpAffine, 10, 253>>::NonIdentityPoint, std::vec::Vec<<SinsemillaChip as sinsemilla::SinsemillaInstructions<pasta_curves::EpAffine, 10, 253>>::RunningSum>), halo2_proofs::plonk::Error>` | note: type in trait --> halo2_gadgets/src/sinsemilla.rs:89:10 | 89 | ) -> Result<(Self::NonIdentityPoint, Vec<Self::RunningSum>), Error>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(&sinsemilla::merkle::chip::MerkleChip<_>, _, pasta_curves::EpAffine, _) -> std::result::Result<(_, std::vec::Vec<<SinsemillaChip as sinsemilla::SinsemillaInstructions<pasta_curves::EpAffine, 10, 253>>::RunningSum>), _>` found signature `fn(&sinsemilla::merkle::chip::MerkleChip<_>, _, pasta_curves::EpAffine, _) -> std::result::Result<(_, std::vec::Vec<std::vec::Vec<<SinsemillaChip as sinsemilla::SinsemillaInstructions<pasta_curves::EpAffine, 10, 253>>::CellValue>>), _>`

Check failure on line 509 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

method `hash_to_point` has an incompatible type for trait

Check failure on line 509 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Book tests

method `hash_to_point` has an incompatible type for trait

Check failure on line 509 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

method `hash_to_point` has an incompatible type for trait

Check failure on line 509 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

method `hash_to_point` has an incompatible type for trait
let config = self.config().sinsemilla_config.clone();

Check failure on line 510 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no field `sinsemilla_config` on type `&sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>`

error[E0609]: no field `sinsemilla_config` on type `&sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:510:36 | 510 | let config = self.config().sinsemilla_config.clone(); | ^^^^^^^^^^^^^^^^^ unknown field | help: a field with a similar name exists | 510 | let config = self.config().sinsemilla_chip.clone(); | ~~~~~~~~~~~~~~~

Check failure on line 510 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no field `sinsemilla_config` on type `&sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>`

error[E0609]: no field `sinsemilla_config` on type `&sinsemilla::merkle::chip::MerkleConfig<SinsemillaChip>` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:510:36 | 510 | let config = self.config().sinsemilla_config.clone(); | ^^^^^^^^^^^^^^^^^ unknown field | help: a field with a similar name exists | 510 | let config = self.config().sinsemilla_chip.clone(); | ~~~~~~~~~~~~~~~
let chip = SinsemillaChip::<Hash, Commit, F, LookupRangeCheckConfig>::construct(config);
chip.hash_to_point(layouter, Q, message)
self.sinsemilla_chip.hash_to_point(layouter, Q, message)

Check failure on line 511 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no field `sinsemilla_chip` on type `&sinsemilla::merkle::chip::MerkleChip<SinsemillaChip>`

error[E0609]: no field `sinsemilla_chip` on type `&sinsemilla::merkle::chip::MerkleChip<SinsemillaChip>` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:511:14 | 511 | self.sinsemilla_chip.hash_to_point(layouter, Q, message) | ^^^^^^^^^^^^^^^ unknown field | help: one of the expressions' fields has a field of the same name | 511 | self.config.sinsemilla_chip.hash_to_point(layouter, Q, message) | +++++++

Check failure on line 511 in halo2_gadgets/src/sinsemilla/merkle/chip.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

no field `sinsemilla_chip` on type `&sinsemilla::merkle::chip::MerkleChip<SinsemillaChip>`

error[E0609]: no field `sinsemilla_chip` on type `&sinsemilla::merkle::chip::MerkleChip<SinsemillaChip>` --> halo2_gadgets/src/sinsemilla/merkle/chip.rs:511:14 | 511 | self.sinsemilla_chip.hash_to_point(layouter, Q, message) | ^^^^^^^^^^^^^^^ unknown field | help: one of the expressions' fields has a field of the same name | 511 | self.config.sinsemilla_chip.hash_to_point(layouter, Q, message) | +++++++
}

fn extract(point: &Self::NonIdentityPoint) -> Self::X {
SinsemillaChip::<Hash, Commit, F, LookupRangeCheckConfig>::extract(point)
SinsemillaChip::extract(point)
}
}
27 changes: 11 additions & 16 deletions halo2_gadgets/src/sinsemilla_opt/merkle/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@ use pasta_curves::pallas;

use crate::{
sinsemilla::{merkle::chip::MerkleChip, primitives as sinsemilla},
sinsemilla_opt::SinsemillaInstructionsOptimized,
utilities_opt::lookup_range_check::DefaultLookupRangeCheckConfigOptimized,
{
ecc::FixedPoints,
sinsemilla::{CommitDomains, HashDomains},
sinsemilla_opt::chip::SinsemillaChipOptimized,
utilities::cond_swap::CondSwapChip,
sinsemilla::SinsemillaInstructions, utilities::cond_swap::CondSwapChip,
utilities_opt::cond_swap::CondSwapInstructionsOptimized,
},
};

impl<Hash, Commit, F> CondSwapInstructionsOptimized<pallas::Base>
for MerkleChip<Hash, Commit, F, DefaultLookupRangeCheckConfigOptimized>
impl<SinsemillaChip> CondSwapInstructionsOptimized<pallas::Base> for MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash>,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
fn mux(
&self,
Expand All @@ -39,13 +32,14 @@ where
}
}

impl<Hash, Commit, F>
// FIXME: uncomment and implement this properly
/*
impl<SinsemillaChip>
SinsemillaInstructionsOptimized<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>
for MerkleChip<Hash, Commit, F, DefaultLookupRangeCheckConfigOptimized>
for MerkleChip<SinsemillaChip>
where
Hash: HashDomains<pallas::Affine>,
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash>,
SinsemillaChip: Chip<pallas::Base>
+ SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }>,
{
#[allow(non_snake_case)]
#[allow(clippy::type_complexity)]
Expand All @@ -60,3 +54,4 @@ where
chip.hash_to_point_with_private_init(layouter, Q, message)
}
}
*/
3 changes: 3 additions & 0 deletions halo2_gadgets/src/utilities/lookup_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,6 @@ pub trait DefaultLookupRangeCheck:
}

impl DefaultLookupRangeCheck for LookupRangeCheckConfig<pallas::Base, { sinsemilla::K }> {}

pub(crate) type DefaultLookupRangeCheckConfig =
LookupRangeCheckConfig<pallas::Base, { sinsemilla::K }>;
Loading

0 comments on commit 8454123

Please sign in to comment.