Skip to content

Commit

Permalink
Merge branch 'main' of github.com:manojkgorle/brainfuckvm
Browse files Browse the repository at this point in the history
  • Loading branch information
soumyathakur44 committed Dec 14, 2024
2 parents 9906aaa + dfe792d commit 07cfc7c
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 65 deletions.
1 change: 1 addition & 0 deletions src/fields/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl Field {
"Field does not have nth root of unity where n > 2^32 or not power of two."
);
let mut root = FieldElement::new(1753635133440165772, self);

let mut order = 1 << 32;

while order != n {
Expand Down
1 change: 1 addition & 0 deletions src/stark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use memory::MemoryTable;
use processor::ProcessorTable;
use instruction::InstructionTable;

use crate::channel;
use crate::merkle::*;
use crate::channel::*;
use crate::fri::*;
Expand Down
7 changes: 6 additions & 1 deletion src/tables/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ impl InstructionTable {
}
}

pub fn extend_column(&mut self, rand_field_elem: u128, challenges: Vec<FieldElement>) {
pub fn extend_column(&mut self, rand_field_elem: u128, challenges: Vec<FieldElement>) ->Vec<FieldElement>{
let mut terminal:Vec<FieldElement>=Vec::new();
let mut ppa = self.table.matrix[0 as usize][Indices::Address as usize]
* challenges[ChallengeIndices::A as usize]
+ self.table.matrix[0 as usize][Indices::CurrentInstruction as usize]
Expand Down Expand Up @@ -120,7 +121,11 @@ impl InstructionTable {
self.table.matrix[(i + 1) as usize][Indices::EvaluationArg as usize] =
pea * challenges[ChallengeIndices::Eta as usize] + weighted_sum;
}

}
terminal.push(ppa);
terminal.push(pea);
terminal
}

pub fn generate_air(&self, challenges: Vec<FieldElement>,tppa:FieldElement,tpea:FieldElement) -> Vec<Polynomial> {
Expand Down
7 changes: 6 additions & 1 deletion src/tables/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl IOTable {

pub fn pad(&mut self) {}

pub fn extend_column_ea(&mut self, rand_field_elem: u128, challenge: FieldElement) {
pub fn extend_column_ea(&mut self, rand_field_elem: u128, challenge: FieldElement)->Vec<FieldElement> {
let mut ea = FieldElement::new(rand_field_elem, self.table.field); // take rand_field_elem as zero if no random secret implementation
self.table.matrix[0][1] = ea;
for i in 0..self.table.length - 1 {
Expand All @@ -47,7 +47,12 @@ impl IOTable {
self.table.matrix[(i + 1) as usize][1] = ea;
//Tea = IOTable.matrix[length-1][1]
}
let mut terminal: Vec<FieldElement>=Vec::new();
terminal.push(ea);
terminal

}

}

#[cfg(test)]
Expand Down
16 changes: 15 additions & 1 deletion src/tables/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ impl MemoryTable {
}

//the matrix taken here is padded
pub fn extend_column_ppa(&mut self, rand_field_elem: u128, challenges: Vec<FieldElement>) {
pub fn extend_column_ppa(&mut self, rand_field_elem: u128, challenges: Vec<FieldElement>)->Vec<FieldElement> {
let mut terminal:Vec<FieldElement>= Vec::new();
let mut ppa = FieldElement::new(rand_field_elem, self.table.field);
self.table.matrix[0][Indices::PermutationArg as usize] = ppa;
for i in 0..self.table.length - 1 {
Expand All @@ -118,7 +119,18 @@ impl MemoryTable {
- challenges[ChallengeIndices::Beta as usize];
ppa *= weighted_sum;
self.table.matrix[(i + 1) as usize][Indices::PermutationArg as usize] = ppa;

}
let mut tppa=ppa*(self.table.matrix[self.table.length as usize][Indices::Cycle as usize]
* challenges[ChallengeIndices::D as usize]
+ self.table.matrix[self.table.length as usize][Indices::MemoryPointer as usize]
* challenges[ChallengeIndices::E as usize]
+ self.table.matrix[self.table.length as usize][Indices::MemoryValue as usize]
* challenges[ChallengeIndices::F as usize]
- challenges[ChallengeIndices::Beta as usize]);
let mut Tppa:Vec<FieldElement>=Vec::new();
Tppa.push(tppa);
Tppa
}

//this is after padding and extension
Expand Down Expand Up @@ -334,4 +346,6 @@ mod test_memory_table {
// println!("{}:{}", ppa.0, i+1);
// }
// }


}
Loading

0 comments on commit 07cfc7c

Please sign in to comment.