feat(prover): Add Memory-mapped private input#508
Closed
ColoCarletti wants to merge 9 commits into
Closed
Conversation
Collaborator
Author
|
/bench |
Benchmark — fib_iterative_8M (median of 3)Table parallelism: 32 (auto = cores / 3)
Commit: 9559d16 · Baseline: cached · Runner: self-hosted bench |
|
Benchmark Results for modified programs 🚀
|
Collaborator
Author
|
/bench |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement memory-mapped private input (pre-loaded at
0xFF000000) replacing the oldGetPrivateInputsecall that was invisible to the proverNew feature: Memory-mapped private input
The old
GetPrivateInputsecall copied bytes into guest memory without emittingLogentries — the prover never saw those writes, so verification always failed for any program readingprivate input.
Now, private input is pre-loaded at
0xFF000000as part of the initial memory image. The guest reads it via normal RISC-V loads. The PAGE table commits to the init values, so the Memorybus balances naturally.
prove_with_input(elf_bytes, private_input)VmProofincludesprivate_input: Vec<u8>so the verifier can reconstruct PAGE commitmentsGetPrivateInputsecall (4) removed entirelyget_private_input()rewritten asread_volatilefrom0xFF000000print_stringcalls insys_halt()andsys_getenv()that were orphan senders on the Ecall busBug fix 1: SRL extension mis-gating (Bus 13 — Shift)
shift::compute_aux()setis_negative = MSB(in[3])regardless of thesignedflag. For logical right shift (SRL,signed=0), this produced wrong output when the input's top bit wasset — the SHIFT table stored arithmetic-shift output instead of logical-shift output.
Fix:
let is_negative = self.signed && (self.in_halves[3] >> 15) & 1 == 1;The spec explicitly permits
is_negativeto be unconstrained whensigned=0(SHIFT-C13's MSB16 lookup is gated bysigned).Bug fix 2: CSR instructions missing PC update (Bus 14 — Memw)
DecodeEntry::from(Instruction::CSR)left all ALU flags atfalse, makingpad=1and CM54's multiplicity 0. The CPU didn't send PC-update tokens for CSR rows, but MEMW_R generatedthem unconditionally — creating orphan receivers.
Fix:
entry.op_add = true;— mirrors the existingInstruction::Fencepattern (no-op asADDI x0, x0, 0).CSR instructions appear in Rust std programs because the toolchain injects
csrrci x10, mstatus, 0during startup.Bug fix 3: W-suffix instructions truncate register values in Log (Bus 16 — Memory)
Instruction::ArithImmWandInstruction::ArithRegWstored the truncated 32-bit value inLog.src1_val/src2_valinstead of the raw 64-bit register value: