Skip to content

Commit

Permalink
added_terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
m-pandey5 committed Dec 7, 2024
1 parent 3cdef6a commit 75085f0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
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
14 changes: 13 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
24 changes: 23 additions & 1 deletion src/tables/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl ProcessorTable {
}

//the matrix taken here is padded
pub fn extend_columns(&mut self, challenges: Vec<FieldElement>) {
pub fn extend_columns(&mut self, challenges: Vec<FieldElement>)->Vec<FieldElement> {
//@todo Note: Taking init 1 for now, change to random secret initial value which we check by difference constraint of tmpa = Tppa
let mut ipa = FieldElement::one(self.table.field);
let mut mpa = FieldElement::one(self.table.field);
Expand All @@ -153,6 +153,13 @@ impl ProcessorTable {
ipa *= weighted_sum;
self.table.matrix[(i + 1) as usize][Indices::InstructionPermutaion as usize] = ipa;
}
let mut tipa=ipa*(self.table.matrix[self.table.length as usize][Indices::InstructionPointer as usize]
* challenges[ChallengeIndices::A as usize]
+ self.table.matrix[self.table.length as usize][Indices::CurrentInstruction as usize]
* challenges[ChallengeIndices::B as usize]
+ self.table.matrix[self.table.length as usize][Indices::NextInstruction as usize]
* challenges[ChallengeIndices::C as usize]
- challenges[ChallengeIndices::Alpha as usize]);

for i in 0..self.table.length - 1 {
let weighted_sum = self.table.matrix[i as usize][Indices::Cycle as usize]
Expand All @@ -165,6 +172,13 @@ impl ProcessorTable {
mpa *= weighted_sum;
self.table.matrix[(i + 1) as usize][Indices::MemoryPermuation as usize] = mpa;
}
let mut tmpa=mpa*(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 f =
|x: char| -> FieldElement { FieldElement::new((x as u32) as u128, self.table.field) };
Expand All @@ -189,6 +203,14 @@ impl ProcessorTable {
self.table.matrix[(i + 1) as usize][Indices::OutputEvaluation as usize] = oea;
}
}
let mut tiea=iea;
let mut toea =oea;
let mut terminal:Vec<FieldElement>=Vec::new();
terminal.push(tipa);
terminal.push(tmpa);
terminal.push(tiea);
terminal.push(toea);
terminal
}

pub fn generate_zerofier(&self) -> Vec<Polynomial> {
Expand Down

0 comments on commit 75085f0

Please sign in to comment.