mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 22:03:07 +00:00
Small nits for the exponentiation gate
This commit is contained in:
parent
36a1386c6f
commit
fc9d64defe
@ -112,11 +112,12 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
base: Target,
|
||||
exponent_bits: impl Iterator<Item = impl Borrow<Target>>,
|
||||
) -> Target {
|
||||
let zero = self.zero();
|
||||
let gate = ExponentiationGate::new(self.config.clone());
|
||||
let num_power_bits = gate.num_power_bits;
|
||||
let mut exp_bits_vec: Vec<Target> = exponent_bits.map(|b| *b.borrow()).collect();
|
||||
while exp_bits_vec.len() < num_power_bits {
|
||||
exp_bits_vec.push(self.constant(F::ZERO));
|
||||
exp_bits_vec.push(zero);
|
||||
}
|
||||
let gate_index = self.add_gate(gate.clone(), vec![]);
|
||||
|
||||
|
||||
@ -29,8 +29,9 @@ impl<F: Extendable<D>, const D: usize> ExponentiationGate<F, D> {
|
||||
}
|
||||
|
||||
fn max_power_bits(num_wires: usize, num_routed_wires: usize) -> usize {
|
||||
let max_for_routed_wires = num_routed_wires - 3;
|
||||
let max_for_wires = (num_wires - 3) / 2;
|
||||
// 2 wires are reserved for the base and output.
|
||||
let max_for_routed_wires = num_routed_wires - 2;
|
||||
let max_for_wires = (num_wires - 2) / 2;
|
||||
max_for_routed_wires.min(max_for_wires)
|
||||
}
|
||||
|
||||
@ -147,7 +148,7 @@ impl<F: Extendable<D>, const D: usize> Gate<F, D> for ExponentiationGate<F, D> {
|
||||
|
||||
let mut constraints = Vec::new();
|
||||
|
||||
let one = builder.constant_extension(F::Extension::ONE);
|
||||
let one = builder.one_extension();
|
||||
for i in 0..self.num_power_bits {
|
||||
let prev_intermediate_value = if i == 0 {
|
||||
one
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user