Change fixed-base exponentiation API to handle scalars better.
This commit is contained in:
parent
88bdff6ce9
commit
a1c749e6a0
|
@ -44,8 +44,7 @@ impl<E: Engine> Clone for EdwardsPoint<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform a fixed-base scalar multiplication with
|
/// Perform a fixed-base scalar multiplication with
|
||||||
/// `by` being in little-endian bit order. `by` must
|
/// `by` being in little-endian bit order.
|
||||||
/// be a multiple of 3.
|
|
||||||
pub fn fixed_base_multiplication<E, CS>(
|
pub fn fixed_base_multiplication<E, CS>(
|
||||||
mut cs: CS,
|
mut cs: CS,
|
||||||
base: FixedGenerators,
|
base: FixedGenerators,
|
||||||
|
@ -55,11 +54,6 @@ pub fn fixed_base_multiplication<E, CS>(
|
||||||
where CS: ConstraintSystem<E>,
|
where CS: ConstraintSystem<E>,
|
||||||
E: JubjubEngine
|
E: JubjubEngine
|
||||||
{
|
{
|
||||||
// We're going to chunk the scalar into 3-bit windows,
|
|
||||||
// so let's force the caller to supply the right number
|
|
||||||
// of bits for our lookups.
|
|
||||||
assert!(by.len() % 3 == 0);
|
|
||||||
|
|
||||||
// Represents the result of the multiplication
|
// Represents the result of the multiplication
|
||||||
let mut result = None;
|
let mut result = None;
|
||||||
|
|
||||||
|
@ -67,9 +61,13 @@ pub fn fixed_base_multiplication<E, CS>(
|
||||||
.zip(params.circuit_generators(base).iter())
|
.zip(params.circuit_generators(base).iter())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
|
let chunk_a = chunk.get(0).map(|e| e.clone()).unwrap_or(Boolean::constant(false));
|
||||||
|
let chunk_b = chunk.get(1).map(|e| e.clone()).unwrap_or(Boolean::constant(false));
|
||||||
|
let chunk_c = chunk.get(2).map(|e| e.clone()).unwrap_or(Boolean::constant(false));
|
||||||
|
|
||||||
let (x, y) = lookup3_xy(
|
let (x, y) = lookup3_xy(
|
||||||
cs.namespace(|| format!("window table lookup {}", i)),
|
cs.namespace(|| format!("window table lookup {}", i)),
|
||||||
chunk,
|
&[chunk_a, chunk_b, chunk_c],
|
||||||
window
|
window
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue