mirror of https://github.com/zcash/orchard.git
Optimise layout of witnessed Sinsemilla message pieces
The Sinsemilla chip witnesses message pieces in individual regions, and then copies them into the `hash_piece` region to initialize the running sum. Previously these occured in the same column, but we can reduce the utilized rows of the Action circuit by moving these into a less-used column. If https://github.com/zcash/halo2/issues/334 is implemented, this change would be unnecessary, as the witnessed message piece regions would never be assigned into the circuit.
This commit is contained in:
parent
bf72e308bd
commit
3462d3e051
|
@ -252,6 +252,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
|
|||
let sinsemilla_config_1 = SinsemillaChip::configure(
|
||||
meta,
|
||||
advices[..5].try_into().unwrap(),
|
||||
advices[6],
|
||||
lookup,
|
||||
range_check.clone(),
|
||||
);
|
||||
|
@ -268,6 +269,7 @@ impl plonk::Circuit<pallas::Base> for Circuit {
|
|||
let sinsemilla_config_2 = SinsemillaChip::configure(
|
||||
meta,
|
||||
advices[5..].try_into().unwrap(),
|
||||
advices[7],
|
||||
lookup,
|
||||
range_check,
|
||||
);
|
||||
|
|
|
@ -484,12 +484,14 @@ mod tests {
|
|||
let config1 = SinsemillaChip::configure(
|
||||
meta,
|
||||
advices[..5].try_into().unwrap(),
|
||||
advices[2],
|
||||
lookup,
|
||||
range_check.clone(),
|
||||
);
|
||||
let config2 = SinsemillaChip::configure(
|
||||
meta,
|
||||
advices[5..].try_into().unwrap(),
|
||||
advices[7],
|
||||
lookup,
|
||||
range_check,
|
||||
);
|
||||
|
|
|
@ -53,6 +53,9 @@ pub struct SinsemillaConfig {
|
|||
/// Advice column used to store the $\lambda_2$ intermediate value at each
|
||||
/// iteration.
|
||||
lambda_2: Column<Advice>,
|
||||
/// Advice column used to witness message pieces. This may or may not be the same
|
||||
/// column as `bits`.
|
||||
witness_pieces: Column<Advice>,
|
||||
/// The lookup table where $(\mathsf{idx}, x_p, y_p)$ are loaded for the $2^K$
|
||||
/// generators of the Sinsemilla hash.
|
||||
pub(super) generator_table: GeneratorTableConfig,
|
||||
|
@ -106,6 +109,7 @@ impl SinsemillaChip {
|
|||
pub fn configure(
|
||||
meta: &mut ConstraintSystem<pallas::Base>,
|
||||
advices: [Column<Advice>; 5],
|
||||
witness_pieces: Column<Advice>,
|
||||
lookup: (Column<Fixed>, Column<Fixed>, Column<Fixed>),
|
||||
range_check: LookupRangeCheckConfig<pallas::Base, { sinsemilla::K }>,
|
||||
) -> <Self as Chip<pallas::Base>>::Config {
|
||||
|
@ -118,6 +122,7 @@ impl SinsemillaChip {
|
|||
bits: advices[2],
|
||||
lambda_1: advices[3],
|
||||
lambda_2: advices[4],
|
||||
witness_pieces,
|
||||
generator_table: GeneratorTableConfig {
|
||||
table_idx: lookup.0,
|
||||
table_x: lookup.1,
|
||||
|
@ -241,7 +246,7 @@ impl SinsemillaInstructions<pallas::Affine, { sinsemilla::K }, { sinsemilla::C }
|
|||
|mut region| {
|
||||
region.assign_advice(
|
||||
|| "witness message piece",
|
||||
config.bits,
|
||||
config.witness_pieces,
|
||||
0,
|
||||
|| field_elem.ok_or(Error::SynthesisError),
|
||||
)
|
||||
|
|
|
@ -702,6 +702,7 @@ mod tests {
|
|||
let sinsemilla_config = SinsemillaChip::configure(
|
||||
meta,
|
||||
advices[..5].try_into().unwrap(),
|
||||
advices[2],
|
||||
lookup,
|
||||
range_check.clone(),
|
||||
);
|
||||
|
|
|
@ -203,6 +203,7 @@ pub mod tests {
|
|||
let sinsemilla_config_1 = SinsemillaChip::configure(
|
||||
meta,
|
||||
advices[5..].try_into().unwrap(),
|
||||
advices[7],
|
||||
lookup,
|
||||
range_check.clone(),
|
||||
);
|
||||
|
@ -211,6 +212,7 @@ pub mod tests {
|
|||
let sinsemilla_config_2 = SinsemillaChip::configure(
|
||||
meta,
|
||||
advices[..5].try_into().unwrap(),
|
||||
advices[2],
|
||||
lookup,
|
||||
range_check,
|
||||
);
|
||||
|
|
|
@ -1364,6 +1364,7 @@ mod tests {
|
|||
let sinsemilla_config = SinsemillaChip::configure(
|
||||
meta,
|
||||
advices[..5].try_into().unwrap(),
|
||||
advices[2],
|
||||
lookup,
|
||||
range_check.clone(),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue