Skip to main content

binius_iop_prover/channel/
grinding.rs

1// Copyright 2026 The Binius Developers
2
3//! Proof-of-work grinding, as a capability a prover channel may carry.
4//!
5//! The counterpart of
6//! [`GrindingVerifierChannel`](binius_iop::channel::grinding::GrindingVerifierChannel). That trait
7//! states the contract both sides obey, and why it is a capability not a method.
8
9/// A prover channel that can pay a proof of work into the transcript.
10///
11/// The mirror of
12/// [`GrindingVerifierChannel`](binius_iop::channel::grinding::GrindingVerifierChannel).
13/// It is a trait of its own for the same reason: grinding acts on the Fiat-Shamir state alone.
14///
15/// # Contract
16///
17/// A difficulty of zero is not a grind, and must leave tape and challenger untouched.
18/// The verifier's trait documents why that rule belongs to the channel rather than the call sites.
19pub trait GrindingProverChannel {
20	/// Searches for a nonce meeting `bits` of difficulty and writes it, returning the nonce.
21	///
22	/// The expected cost is `2^bits` challenger trials, paid in wall clock.
23	///
24	/// ## Preconditions
25	///
26	/// * `bits` is at most [`MAX_GRINDING_BITS`](binius_transcript::MAX_GRINDING_BITS).
27	fn grind(&mut self, bits: usize) -> u64;
28}