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
14 changes: 7 additions & 7 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ use halo2_gadgets::{
},
utilities::{
bool_check,
cond_swap::{CondSwapChip, CondSwapConfig},
lookup_range_check::LookupRangeCheckConfig,
mux::{MuxChip, MuxConfig},
},
};

Expand Down Expand Up @@ -103,7 +103,7 @@ pub struct Config {
commit_ivk_config: CommitIvkConfig,
old_note_commit_config: NoteCommitConfig,
new_note_commit_config: NoteCommitConfig,
mux_config: MuxConfig,
cond_swap_config: CondSwapConfig,
}

/// The Orchard Action circuit.
Expand Down Expand Up @@ -455,7 +455,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
let new_note_commit_config =
NoteCommitChip::configure(meta, advices, sinsemilla_config_2.clone());

let mux_config = MuxChip::configure(meta, advices[0], advices[1], advices[2], advices[3]);
let cond_swap_config = CondSwapChip::configure(meta, advices[0..5].try_into().unwrap());

Config {
primary,
Expand All @@ -471,7 +471,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
commit_ivk_config,
old_note_commit_config,
new_note_commit_config,
mux_config,
cond_swap_config,
}
}

Expand Down Expand Up @@ -668,7 +668,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
config.poseidon_chip(),
config.add_chip(),
ecc_chip.clone(),
config.mux_chip(),
config.cond_swap_chip(),
rho_old.clone(),
&psi_nf,
&cm_old,
Expand Down Expand Up @@ -764,7 +764,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
config.sinsemilla_chip_1(),
config.ecc_chip(),
config.note_commit_chip_old(),
config.mux_chip(),
config.cond_swap_chip(),
g_d_old.inner(),
pk_d_old.inner(),
v_old.clone(),
Expand Down Expand Up @@ -825,7 +825,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
config.sinsemilla_chip_2(),
config.ecc_chip(),
config.note_commit_chip_new(),
config.mux_chip(),
config.cond_swap_chip(),
g_d_new.inner(),
pk_d_new.inner(),
v_new.clone(),
Expand Down
10 changes: 5 additions & 5 deletions src/circuit/gadget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use halo2_gadgets::{
Hash as PoseidonHash, PoseidonSpongeInstructions, Pow5Chip as PoseidonChip,
},
sinsemilla::{chip::SinsemillaChip, merkle::chip::MerkleChip},
utilities::mux::{MuxChip, MuxInstructions},
utilities::cond_swap::CondSwapChip,
};
use halo2_proofs::{
circuit::{AssignedCell, Chip, Layouter, Value},
Expand Down Expand Up @@ -73,8 +73,8 @@ impl super::Config {
NoteCommitChip::construct(self.old_note_commit_config.clone())
}

pub(super) fn mux_chip(&self) -> MuxChip {
MuxChip::construct(self.mux_config.clone())
pub(super) fn cond_swap_chip(&self) -> CondSwapChip<pallas::Base> {
CondSwapChip::construct(self.cond_swap_config.clone())
}
}

Expand Down Expand Up @@ -170,7 +170,7 @@ pub(in crate::circuit) fn derive_nullifier<
poseidon_chip: PoseidonChip,
add_chip: AddChip,
ecc_chip: EccChip,
mux_chip: MuxChip,
cond_swap_chip: CondSwapChip<pallas::Base>,
rho: AssignedCell<pallas::Base, pallas::Base>,
psi: &AssignedCell<pallas::Base, pallas::Base>,
cm: &Point<pallas::Affine, EccChip>,
Expand Down Expand Up @@ -223,7 +223,7 @@ pub(in crate::circuit) fn derive_nullifier<
// Select the desired nullifier according to split_flag
Ok(Point::from_inner(
ecc_chip,
mux_chip.mux_on_points(
cond_swap_chip.mux_on_points(
layouter.namespace(|| "mux on nf"),
&split_flag,
nf.inner(),
Expand Down
32 changes: 17 additions & 15 deletions src/circuit/note_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ use halo2_gadgets::{
CommitDomain, Message, MessagePiece,
},
utilities::{
bool_check,
lookup_range_check::LookupRangeCheckConfig,
mux::{MuxChip, MuxInstructions},
bool_check, cond_swap::CondSwapChip, lookup_range_check::LookupRangeCheckConfig,
FieldValue, RangeConstrained,
},
};
Expand Down Expand Up @@ -1747,7 +1745,7 @@ pub(in crate::circuit) mod gadgets {
chip: SinsemillaChip<OrchardHashDomains, OrchardCommitDomains, OrchardFixedBases>,
ecc_chip: EccChip<OrchardFixedBases>,
note_commit_chip: NoteCommitChip,
mux_chip: MuxChip,
cond_swap_chip: CondSwapChip<pallas::Base>,
g_d: &NonIdentityEccPoint,
pk_d: &NonIdentityEccPoint,
value: AssignedCell<NoteValue, pallas::Base>,
Expand Down Expand Up @@ -1902,7 +1900,7 @@ pub(in crate::circuit) mod gadgets {
Value::known(zsa_domain.q_init()),
)?;

mux_chip.mux_on_non_identity_points(
cond_swap_chip.mux_on_non_identity_points(
layouter.namespace(|| "mux on hash point"),
&is_native_asset,
q_init_zsa.inner(),
Expand Down Expand Up @@ -1939,7 +1937,7 @@ pub(in crate::circuit) mod gadgets {
// hash_point = hash_zsa if is_native_asset is false
let hash_point = Point::from_inner(
ecc_chip,
mux_chip.mux_on_points(
cond_swap_chip.mux_on_points(
layouter.namespace(|| "mux on hash point"),
&is_native_asset,
&(hash_point_zsa.inner().clone().into()),
Expand Down Expand Up @@ -2342,8 +2340,8 @@ mod tests {
},
sinsemilla::chip::SinsemillaChip,
utilities::{
cond_swap::{CondSwapChip, CondSwapConfig},
lookup_range_check::LookupRangeCheckConfig,
mux::{MuxChip, MuxConfig},
},
};

Expand All @@ -2370,7 +2368,11 @@ mod tests {
}

impl Circuit<pallas::Base> for MyCircuit {
type Config = (NoteCommitConfig, EccConfig<OrchardFixedBases>, MuxConfig);
type Config = (
NoteCommitConfig,
EccConfig<OrchardFixedBases>,
CondSwapConfig,
);
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
Expand Down Expand Up @@ -2446,18 +2448,18 @@ mod tests {
range_check,
);

let mux_config =
MuxChip::configure(meta, advices[0], advices[1], advices[2], advices[3]);
let cond_swap_config =
CondSwapChip::configure(meta, advices[0..5].try_into().unwrap());

(note_commit_config, ecc_config, mux_config)
(note_commit_config, ecc_config, cond_swap_config)
}

fn synthesize(
&self,
config: Self::Config,
mut layouter: impl Layouter<pallas::Base>,
) -> Result<(), Error> {
let (note_commit_config, ecc_config, mux_config) = config;
let (note_commit_config, ecc_config, cond_swap_config) = config;

// Load the Sinsemilla generator lookup table used by the whole circuit.
SinsemillaChip::<
Expand All @@ -2476,8 +2478,8 @@ mod tests {
// Construct a NoteCommit chip
let note_commit_chip = NoteCommitChip::construct(note_commit_config.clone());

// Construct a Mux chip
let mux_chip = MuxChip::construct(mux_config);
// Construct a CondSwap chip
let cond_swap_chip = CondSwapChip::construct(cond_swap_config);

// Witness g_d
let g_d = NonIdentityPoint::new(
Expand Down Expand Up @@ -2544,7 +2546,7 @@ mod tests {
sinsemilla_chip,
ecc_chip.clone(),
note_commit_chip,
mux_chip,
cond_swap_chip,
g_d.inner(),
pk_d.inner(),
value_var,
Expand Down
Loading