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

audit #158

Merged
merged 2 commits into from
Nov 1, 2024
Merged

audit #158

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
Binary file added audit/zksecurity.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion src/air/layouts/_generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def main():

for layout, settings in layout_settings.items():
handle_github_file(
f"https://raw.githubusercontent.com/starkware-libs/cairo-lang/master/src/starkware/cairo/stark_verifier/air/layouts/{layout}/autogenerated.cairo",
f"https://raw.githubusercontent.com/starkware-libs/cairo-lang/a86e92bfde9c171c0856d7b46580c66e004922f3/src/starkware/cairo/stark_verifier/air/layouts/{layout}/autogenerated.cairo",
f"../{layout}/autogenerated.cairo",
layout,
settings
Expand Down
5 changes: 1 addition & 4 deletions src/air/layouts/dex/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ impl DexPublicInputImpl of PublicInputTrait {
let output_hash = poseidon_hash_span(output);

// Check main page len
assert(
*memory.at(memory_index - 1) == *self.main_page.at(self.main_page.len() - 1),
'Invalid main page len'
);
assert(memory_index == self.main_page.len(), 'Invalid main page len');

(program_hash, output_hash)
}
Expand Down
4 changes: 1 addition & 3 deletions src/air/layouts/recursive/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ impl RecursivePublicInputImpl of PublicInputTrait {
let output_hash = poseidon_hash_span(output);

// Check main page len
assert(
*memory.at(memory_index - 1) == *memory.at(memory.len() - 1), 'Invalid main page len'
);
assert(memory_index == self.main_page.len(), 'Invalid main page len');

(program_hash, output_hash)
}
Expand Down
5 changes: 1 addition & 4 deletions src/air/layouts/recursive_with_poseidon/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ impl RecursiveWithPoseidonPublicInputImpl of PublicInputTrait {
let output_hash = poseidon_hash_span(output);

// Check main page len
assert(
*memory.at(memory_index - 1) == *self.main_page.at(self.main_page.len() - 1),
'Invalid main page len'
);
assert(memory_index == self.main_page.len(), 'Invalid main page len');

(program_hash, output_hash)
}
Expand Down
5 changes: 1 addition & 4 deletions src/air/layouts/small/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ impl SmallPublicInputImpl of PublicInputTrait {
let output_hash = poseidon_hash_span(output);

// Check main page len
assert(
*memory.at(memory_index - 1) == *self.main_page.at(self.main_page.len() - 1),
'Invalid main page len'
);
assert(memory_index == self.main_page.len(), 'Invalid main page len');

(program_hash, output_hash)
}
Expand Down
5 changes: 1 addition & 4 deletions src/air/layouts/starknet/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ impl StarknetPublicInputImpl of PublicInputTrait {
let output_hash = poseidon_hash_span(output);

// Check main page len
assert(
*memory.at(memory_index - 1) == *self.main_page.at(self.main_page.len() - 1),
'Invalid main page len'
);
assert(memory_index == self.main_page.len(), 'Invalid main page len');

(program_hash, output_hash)
}
Expand Down
5 changes: 1 addition & 4 deletions src/air/layouts/starknet_with_keccak/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ impl StarknetWithKeccakPublicInputImpl of PublicInputTrait {
let output_hash = poseidon_hash_span(output);

// Check main page len
assert(
*memory.at(memory_index - 1) == *self.main_page.at(self.main_page.len() - 1),
'Invalid main page len'
);
assert(memory_index == self.main_page.len(), 'Invalid main page len');

(program_hash, output_hash)
}
Expand Down
4 changes: 4 additions & 0 deletions src/fri/fri.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ fn fri_commit(
ref channel: Channel, unsent_commitment: FriUnsentCommitment, config: FriConfig
) -> FriCommitment {
assert((*config.fri_step_sizes.at(0)) == 0, 'Invalid value');
assert(
unsent_commitment.inner_layers.len().into() == config.n_layers - 1,
'Invalid inner layer commitments'
);

let (commitments, eval_points) = fri_commit_rounds(
ref channel,
Expand Down
3 changes: 3 additions & 0 deletions src/fri/fri_config.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ impl FriConfigImpl of FriConfigTrait {
*self.log_last_layer_degree_bound <= MAX_LAST_LAYER_LOG_DEGREE_BOUND, 'Value too big'
);
assert(*self.fri_step_sizes[0] == 0, 'Invalid value');
assert(
(*self.inner_layers).len().into() == *self.n_layers - 1, 'Invalid inner layer config'
);

let mut i: u32 = 1;
let n_layers: u32 = (*self.n_layers).try_into().unwrap();
Expand Down
Loading