Skip to content

Commit

Permalink
Merge pull request #158 from HerodotusDev/audit
Browse files Browse the repository at this point in the history
audit
  • Loading branch information
Okm165 authored Nov 1, 2024
2 parents 1725315 + 193e6d5 commit db78e0e
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 24 deletions.
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

0 comments on commit db78e0e

Please sign in to comment.