Skip to content

Commit 3df476e

Browse files
committed
add max private input size
1 parent d610c84 commit 3df476e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

prover/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,21 @@ pub fn verify_with_options(
668668
// A malicious prover could set counts to 0, removing entire constraint sets.
669669
vm_proof.table_counts.validate()?;
670670

671+
// Bound num_private_input_pages before allocating PageConfigs.
672+
// MAX_PRIVATE_INPUT_SIZE fits in ~26 pages of DEFAULT_PAGE_SIZE.
673+
{
674+
use executor::vm::memory::MAX_PRIVATE_INPUT_SIZE;
675+
use crate::tables::page::DEFAULT_PAGE_SIZE;
676+
let max_pages =
677+
(MAX_PRIVATE_INPUT_SIZE as usize + 4 + DEFAULT_PAGE_SIZE - 1) / DEFAULT_PAGE_SIZE + 1;
678+
if vm_proof.num_private_input_pages > max_pages {
679+
return Err(Error::InvalidTableCounts(format!(
680+
"num_private_input_pages ({}) exceeds max ({max_pages})",
681+
vm_proof.num_private_input_pages,
682+
)));
683+
}
684+
}
685+
671686
let program = Elf::load(elf_bytes).map_err(|e| Error::ElfLoad(format!("{e}")))?;
672687
let page_configs = Traces::page_configs_from_elf_and_runtime(
673688
&program,

0 commit comments

Comments
 (0)