mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 16:23:12 +00:00
fixes
This commit is contained in:
parent
c2439557bf
commit
4ea1df82ba
@ -22,7 +22,6 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
b.len(),
|
||||
"Permutation must have same number of inputs and outputs"
|
||||
);
|
||||
assert_eq!(a[0].len(), b[0].len(), "Chunk sizes must be the same");
|
||||
|
||||
match a.len() {
|
||||
// Two empty lists are permutations of one another, trivially.
|
||||
@ -455,7 +454,6 @@ mod tests {
|
||||
#[test]
|
||||
fn test_permutation_2x2() -> Result<()> {
|
||||
type F = CrandallField;
|
||||
type FF = QuarticCrandallField;
|
||||
let config = CircuitConfig::large_config();
|
||||
let pw = PartialWitness::new(config.num_wires);
|
||||
let mut builder = CircuitBuilder::<F, 4>::new(config);
|
||||
@ -482,7 +480,6 @@ mod tests {
|
||||
#[test]
|
||||
fn test_permutation_4x4() -> Result<()> {
|
||||
type F = CrandallField;
|
||||
type FF = QuarticCrandallField;
|
||||
let config = CircuitConfig::large_config();
|
||||
let pw = PartialWitness::new(config.num_wires);
|
||||
let mut builder = CircuitBuilder::<F, 4>::new(config);
|
||||
|
||||
@ -213,10 +213,7 @@ impl<F: Extendable<D>, const D: usize, const CHUNK_SIZE: usize> SimpleGenerator<
|
||||
SwitchGate::<F, D, CHUNK_SIZE>::wire_second_input(self.copy, e),
|
||||
));
|
||||
deps.push(local_target(
|
||||
SwitchGate::<F, D, CHUNK_SIZE>::wire_first_output(self.copy, e),
|
||||
));
|
||||
deps.push(local_target(
|
||||
SwitchGate::<F, D, CHUNK_SIZE>::wire_second_output(self.copy, e),
|
||||
SwitchGate::<F, D, CHUNK_SIZE>::wire_switch_bool(self.copy, e),
|
||||
));
|
||||
}
|
||||
|
||||
@ -231,7 +228,11 @@ impl<F: Extendable<D>, const D: usize, const CHUNK_SIZE: usize> SimpleGenerator<
|
||||
|
||||
let get_local_wire = |input| witness.get_wire(local_wire(input));
|
||||
|
||||
let switch_bool_wire = local_wire(SwitchGate::<F, D, CHUNK_SIZE>::wire_switch_bool(
|
||||
let first_output_wire = local_wire(SwitchGate::<F, D, CHUNK_SIZE>::wire_first_output(
|
||||
self.gate.num_copies,
|
||||
self.copy,
|
||||
));
|
||||
let second_output_wire = local_wire(SwitchGate::<F, D, CHUNK_SIZE>::wire_second_output(
|
||||
self.gate.num_copies,
|
||||
self.copy,
|
||||
));
|
||||
@ -239,15 +240,21 @@ impl<F: Extendable<D>, const D: usize, const CHUNK_SIZE: usize> SimpleGenerator<
|
||||
let first_input = get_local_wire(SwitchGate::<F, D, CHUNK_SIZE>::wire_first_input(
|
||||
self.copy, e,
|
||||
));
|
||||
let first_output = get_local_wire(SwitchGate::<F, D, CHUNK_SIZE>::wire_first_output(
|
||||
let second_input = get_local_wire(SwitchGate::<F, D, CHUNK_SIZE>::wire_second_input(
|
||||
self.copy, e,
|
||||
));
|
||||
let switch_bool = get_local_wire(SwitchGate::<F, D, CHUNK_SIZE>::wire_switch_bool(
|
||||
self.copy, e,
|
||||
));
|
||||
|
||||
if first_input == first_output {
|
||||
out_buffer.set_wire(switch_bool_wire, F::ONE);
|
||||
let (first_output, second_output) = if switch_bool == F::ZERO {
|
||||
(first_input, second_input)
|
||||
} else {
|
||||
out_buffer.set_wire(switch_bool_wire, F::ZERO);
|
||||
}
|
||||
(second_input, first_input)
|
||||
};
|
||||
|
||||
out_buffer.set_wire(first_output_wire, first_output);
|
||||
out_buffer.set_wire(second_output_wire, second_output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user