mirror of
https://github.com/lux-apps/papers.git
synced 2026-10-30 18:15:21 +00:00
Restructured from flat .tex/.pdf files into per-paper subdirectories. Added Antje Worring as co-author on all papers. Synced PDFs to pdfs/ for download site.
55 lines
1.2 KiB
TeX
55 lines
1.2 KiB
TeX
\section{References Implementation Code}
|
|
|
|
|
|
Key implementation snippets for reference:
|
|
|
|
\begin{lstlisting}[language=C, caption=Bisection Game Implementation (Rust)]
|
|
pub struct BisectionGame {
|
|
challenger: Address,
|
|
defender: Address,
|
|
start_state: StateRoot,
|
|
end_state: StateRoot,
|
|
current_round: u32,
|
|
search_space: (u64, u64),
|
|
}
|
|
|
|
impl BisectionGame {
|
|
pub fn submit_bisection(
|
|
&mut self,
|
|
midpoint: u64,
|
|
midpoint_hash: Hash,
|
|
proof: Vec<u8>,
|
|
) -> Result<(), Error> {
|
|
// Verify proof
|
|
self.verify_bisection_proof(midpoint, midpoint_hash, &proof)?;
|
|
|
|
// Update search space
|
|
self.current_round += 1;
|
|
|
|
// Check if complete
|
|
if self.search_space.1 - self.search_space.0 == 1 {
|
|
self.resolve_with_one_step_proof()?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn verify_bisection_proof(
|
|
&self,
|
|
midpoint: u64,
|
|
hash: Hash,
|
|
proof: &[u8],
|
|
) -> Result<(), Error> {
|
|
// Verify Merkle proof
|
|
let computed_hash = self.compute_state_hash(midpoint, proof)?;
|
|
|
|
if computed_hash != hash {
|
|
return Err(Error::InvalidProof);
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|
|
\end{lstlisting}
|
|
|