Skip to content

Commit 47ee66c

Browse files
committed
Add Uint256Mul circuit
1 parent c72b341 commit 47ee66c

File tree

7 files changed

+477
-48
lines changed

7 files changed

+477
-48
lines changed

ceno_zkvm/src/gadgets/field/range.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ impl<Expr: Clone, P: FieldParameters> FieldLtCols<Expr, P> {
205205
let mut sum_flags: Expression<E> = 0.into();
206206
for flag in self.byte_flags.0.iter() {
207207
// Assert that the flag is boolean.
208-
builder.assert_bit(|| "if cond, flag", cond.expr() * flag.expr())?;
208+
// It should be builder.assert_bit(|| "if cond, flag", cond.expr() * flag.expr())?;
209+
// But this makes the degree of sumcheck to be 5 (which is not supported by the backend),
210+
// therefore, we just assume byte flags are boolean no matter cond is 1 or 0.
211+
builder.assert_bit(|| "flag", flag.expr())?;
209212
// Add the flag to the sum.
210213
sum_flags = sum_flags.clone() + flag.expr();
211214
}

ceno_zkvm/src/gadgets/is_zero.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl IsZeroOperation<WitIn> {
5858
builder: &mut CircuitBuilder<E>,
5959
a: Expression<E>,
6060
) -> Result<(), CircuitBuilderError> {
61-
let one: Expression<E> = Expression::ZERO;
61+
let one: Expression<E> = Expression::ONE;
6262

6363
// 1. Input == 0 => is_zero = 1 regardless of the inverse.
6464
// 2. Input != 0
@@ -100,6 +100,7 @@ impl<F: SmallField> IsZeroOperation<F> {
100100
}
101101
let prod = self.inverse * a;
102102
debug_assert!(prod == F::ONE || prod == F::ZERO);
103+
debug_assert_eq!(self.result, F::ONE - self.inverse * a);
103104
(a == F::ZERO) as u32
104105
}
105106
}

ceno_zkvm/src/precompiles/lookup_keccakf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ pub fn setup_gkr_circuit<E: ExtensionField>()
10151015
fields(profiling_1)
10161016
)]
10171017
pub fn run_faster_keccakf<E: ExtensionField, PCS: PolynomialCommitmentScheme<E> + 'static>(
1018-
(layout, gkr_circuit, num_witin, num_structual_witin): (
1018+
(layout, gkr_circuit, num_witin, num_structural_witin): (
10191019
TestKeccakLayout<E>,
10201020
GKRCircuit<E>,
10211021
u16,
@@ -1068,7 +1068,7 @@ pub fn run_faster_keccakf<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>
10681068
);
10691069
let mut structural_witness = RowMajorMatrix::<E::BaseField>::new(
10701070
layout.layout.phase1_witin_rmm_height(states.len()),
1071-
num_structual_witin as usize,
1071+
num_structural_witin as usize,
10721072
InstancePaddingStrategy::Default,
10731073
);
10741074
let raw_witin_iter =

0 commit comments

Comments
 (0)