-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d00905f
commit 1139412
Showing
4 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ mod composition; | |
mod global_values; | ||
mod constants; | ||
mod public_input; | ||
mod public_memory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#[derive(Drop)] | ||
struct AddrValue { | ||
address: felt252, | ||
value: felt252 | ||
} | ||
|
||
type Page = Array<AddrValue>; | ||
|
||
// Information about a continuous page (a consecutive section of the public memory).. | ||
// Each such page must be verified externally to the verifier: | ||
// hash = Hash( | ||
// memory[start_address], memory[start_address + 1], ..., memory[start_address + size - 1]). | ||
// prod = prod_i (z - ((start_address + i) + alpha * (memory[start_address + i])). | ||
// z, alpha are taken from the interaction values, and can be obtained directly from the | ||
// StarkProof object. | ||
// z = interaction_elements.memory_multi_column_perm_perm__interaction_elm | ||
// alpha = interaction_elements.memory_multi_column_perm_hash_interaction_elm0 | ||
#[derive(Drop)] | ||
struct ContinuousPageHeader { | ||
// Start address. | ||
//start_address: felt252, | ||
// Size of the page. | ||
size: felt252, | ||
// Hash of the page. | ||
//hash: u256 | ||
// Cumulative product of the page. | ||
prod: felt252, | ||
} | ||
|
||
#[generate_trait] | ||
impl PageImpl of PageTrait { | ||
// Returns the product of (z - (addr + alpha * val)) over a single page. | ||
fn get_product( | ||
self: @Page, | ||
z: felt252, | ||
alpha: felt252 | ||
) -> felt252 { | ||
let mut res = 1; | ||
let mut i = 0; | ||
loop { | ||
if i == self.len() { | ||
break res; | ||
} | ||
let current = self.at(i); | ||
|
||
res *= z - (*current.address + alpha * *current.value); | ||
} | ||
} | ||
} | ||
|
||
fn get_continuous_pages_product(page_headers: Span<ContinuousPageHeader>) -> (felt252, felt252) { | ||
let mut res = 1; | ||
let mut total_length = 0; | ||
let mut i = 0; | ||
loop { | ||
if i == page_headers.len() { | ||
break (res, total_length); | ||
} | ||
let current = page_headers.at(i); | ||
|
||
res *= *current.prod; | ||
total_length += *current.size; | ||
} | ||
} | ||
|