diff --git a/src/tables/instruction.rs b/src/tables/instruction.rs index fbb85f4..6505f6c 100644 --- a/src/tables/instruction.rs +++ b/src/tables/instruction.rs @@ -83,7 +83,8 @@ impl InstructionTable { } } - pub fn extend_column(&mut self, rand_field_elem: u128, challenges: Vec) { + pub fn extend_column(&mut self, rand_field_elem: u128, challenges: Vec) ->Vec{ + let mut terminal:Vec=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] @@ -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,tppa:FieldElement,tpea:FieldElement) -> Vec { diff --git a/src/tables/io.rs b/src/tables/io.rs index ba509a5..7908cab 100644 --- a/src/tables/io.rs +++ b/src/tables/io.rs @@ -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 { 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 { @@ -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=Vec::new(); + terminal.push(ea); + terminal + } + } #[cfg(test)] diff --git a/src/tables/memory.rs b/src/tables/memory.rs index c23971c..3711e06 100644 --- a/src/tables/memory.rs +++ b/src/tables/memory.rs @@ -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) { + pub fn extend_column_ppa(&mut self, rand_field_elem: u128, challenges: Vec)->Vec { + let mut terminal:Vec= 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 { @@ -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=Vec::new(); + Tppa.push(tppa); + Tppa } //this is after padding and extension diff --git a/src/tables/processor.rs b/src/tables/processor.rs index f9fe252..e43d7e4 100644 --- a/src/tables/processor.rs +++ b/src/tables/processor.rs @@ -129,7 +129,7 @@ impl ProcessorTable { } //the matrix taken here is padded - pub fn extend_columns(&mut self, challenges: Vec) { + pub fn extend_columns(&mut self, challenges: Vec)->Vec { //@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); @@ -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] @@ -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) }; @@ -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=Vec::new(); + terminal.push(tipa); + terminal.push(tmpa); + terminal.push(tiea); + terminal.push(toea); + terminal } pub fn generate_zerofier(&self) -> Vec {