Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Initial starter template for RLC trick for subarray #147

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion plonky2x/src/frontend/eth/mpt/rlc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use std::marker::PhantomData;

use plonky2::hash::poseidon::PoseidonHash;
use plonky2::iop::challenger::RecursiveChallenger;

use super::generators::SubarrayEqualGenerator;
use crate::prelude::{BoolVariable, ByteVariable, CircuitBuilder, PlonkParameters, Variable};

Expand Down Expand Up @@ -35,7 +38,7 @@ impl<L: PlonkParameters<D>, const D: usize> CircuitBuilder<L, D> {
b_offset: Variable,
len: Variable,
) {
// TODO: implement
// TODO: instead of using the SubarrayEqualGenerator below that doesn't actually check anything, implement an RLC check here
let generator: SubarrayEqualGenerator<L, D> = SubarrayEqualGenerator {
a: a.to_vec(),
a_offset,
Expand All @@ -45,6 +48,19 @@ impl<L: PlonkParameters<D>, const D: usize> CircuitBuilder<L, D> {
_phantom: PhantomData::<L>,
};
self.add_simple_generator(generator);

// The following methods might be helpful
let mut challenger = RecursiveChallenger::<L::Field, PoseidonHash, D>::new(&mut self.api);
let challenger_seed = Vec::new(); // TODO: have to "seed" the challenger with some random inputs from the circuit
challenger.observe_elements(&challenger_seed);

let random_variables = challenger.get_n_challenges(&mut self.api, 1);
let random_variable = random_variables[0];

// To convert from a Target to a Variable, just use Variable(my_target) to get a Variable

// TODO: now compute a commitment to a[a_offset:a_offset+len]
// TODO: now compute a commitment to b[b_offset:b_offset+len]
}
}

Expand Down
Loading