Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 4c1c05d

Browse files
committed
howto
1 parent ef73a32 commit 4c1c05d

File tree

2 files changed

+25
-50
lines changed

2 files changed

+25
-50
lines changed

crates/shielder-circuits/src/chips/scalar_multiply.rs

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -85,55 +85,30 @@ impl ScalarMultiplyChip {
8585
) -> Result<GrumpkinPoint<AssignedCell>, Error> {
8686
let ScalarMultiplyChipInput { scalar_bits, input } = inputs;
8787

88-
// let mut input_value: GrumpkinPoint<Value> = input.clone().into();
89-
// let mut result_value: GrumpkinPoint<Value> = GrumpkinPoint::<Fr>::zero().into();
90-
// let mut last_result = None;
91-
92-
// for (i, bit) in scalar_bits.iter().enumerate() {
93-
// let input = input_value.embed(synthesizer, "input")?;
94-
// let result = result_value.embed(synthesizer, "result")?;
95-
// if i.eq(&0) {
96-
// self.constrain_point_at_infinity(synthesizer, result.clone())?;
97-
// self.constrain_points_equality(synthesizer, input.clone(), inputs.input.clone())?;
98-
// }
99-
100-
// let mut is_one = false;
101-
// bit.value().map(|f| {
102-
// is_one = Fr::ONE == *f;
103-
// });
104-
105-
// let mut next_result_value = result_value;
106-
// if is_one {
107-
// next_result_value = curve_arithmetic::points_add(result_value, input_value);
108-
// }
109-
110-
// let next_result = next_result_value.embed(synthesizer, "next_result")?;
111-
112-
// let next_input_value = curve_arithmetic::point_double(input_value);
113-
// let next_input = next_input_value.embed(synthesizer, "next_input")?;
114-
115-
// self.multiply_gate.apply_in_new_region(
116-
// synthesizer,
117-
// ScalarMultiplyGateInput {
118-
// bit: bit.clone(),
119-
// input,
120-
// result,
121-
// next_input,
122-
// next_result: next_result.clone(),
123-
// },
124-
// )?;
125-
126-
// input_value = next_input_value;
127-
// result_value = next_result_value;
128-
129-
// if i.eq(&(scalar_bits.len() - 1)) {
130-
// last_result = Some(next_result);
131-
// }
132-
// }
133-
134-
// Ok(last_result.expect("last result is returned"))
135-
136-
todo!()
88+
// let bits: Vec<V> = scalar_bits
89+
// .iter()
90+
// .map(|cell| V(cell.value().cloned()))
91+
// .collect();
92+
// let bits: [V; 254] = bits.try_into().expect("not 254 bit array");
93+
// let input: GrumpkinPoint<V> = GrumpkinPoint {
94+
// x: V(p.x.value().cloned()),
95+
// y: V(p.y.value().cloned()),
96+
// z: V(p.z.value().cloned()),
97+
// };
98+
99+
let result_value: GrumpkinPoint<Value> = curve_arithmetic::scalar_multiply(input, bits);
100+
101+
let result = result_value.embed(synthesizer, "S")?;
102+
103+
self.multiply_gate.apply_in_new_region(
104+
synthesizer,
105+
ScalarMultiplyGateInput {
106+
scalar_bits: scalar_bits.clone(),
107+
input: input.clone(),
108+
},
109+
)?;
110+
111+
Ok(result)
137112
}
138113
}
139114

crates/shielder-circuits/src/gates/scalar_multiply.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ mod tests {
257257

258258
use halo2_proofs::{
259259
dev::{MockProver, VerifyFailure},
260-
halo2curves::{bn256::Fr, ff::PrimeField, group::Group, grumpkin::G1},
260+
halo2curves::{bn256::Fr, ff::PrimeField},
261261
};
262262
use rand::RngCore;
263263

0 commit comments

Comments
 (0)