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/operand chunks #89

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions jolt-core/src/jolt/instruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub trait JoltInstruction {
fn g_poly_degree(&self, C: usize) -> usize;
fn subtables<F: PrimeField>(&self, C: usize) -> Vec<Box<dyn LassoSubtable<F>>>;
fn to_indices(&self, C: usize, log_M: usize) -> Vec<usize>;
fn operand_chunks(&self, C: usize, log_M: usize) -> (Vec<u64>, Vec<u64>);
}

pub trait Opcode {
Expand Down
10 changes: 10 additions & 0 deletions jolt-core/src/utils/instruction_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ pub fn concatenate_lookups<F: PrimeField>(vals: &[F], C: usize, shift_bits: usiz
sum
}

pub fn chunk_operand(x: u64, num_chunks: usize, bits_per_chunk: usize) -> Vec<u64> {
let bit_mask = (1 << bits_per_chunk) - 1;
(0..num_chunks)
.map(|i| {
let shift = ((num_chunks - i - 1) * bits_per_chunk) as u32;
x.checked_shr(shift).unwrap_or(0) & bit_mask
})
.collect()
}

pub fn chunk_and_concatenate_operands(x: u64, y: u64, C: usize, log_M: usize) -> Vec<usize> {
let operand_bits: usize = log_M / 2;
let operand_bit_mask: usize = (1 << operand_bits) - 1;
Expand Down