pub trait PowTranscriptExt: Transcript {
// Provided method
fn verifier_message_pow<T, S>(
&mut self,
bits: f64,
) -> Result<T, VerificationError>
where T: FromUniform,
S: PowStrategy { ... }
}Expand description
Proof-of-work-protected verifier messages for interactive transcripts.
This extension is available on every Transcript, including concrete
ProverState and
VerifierState values and the generic transcript
passed to Argument::run.
Both parties run the same protocol: obtain a 32-byte grinding challenge,
exchange a little-endian u64 nonce, check it, then obtain the protected
verifier message. Grinding is a prover-only computation; the verifier checks
the received nonce without running the search.
A rejected nonce fails Transcript::check, permanently rejecting the
verifier’s transcript even if the error is caught. The protected message is
produced only after a successful check. Truncated nonces fail during the
prover-message read.
§Protocol parameters
The PoW strategy, difficulty, position of this step, and the codec of the protected message must be fixed by the protocol and accounted for in its session tag. The difficulty must not come from an untrusted proof value. Any soundness benefit depends on the surrounding protocol and PoW strategy.
§Example
use spongefish::{Argument, Narg, Transcript, VerificationError, Witness};
use spongefish_pow::{blake3::Blake3PoW, PowTranscriptExt};
struct PowRound;
impl Argument for PowRound {
type Instance = u32;
type Witness = ();
type Output = u32;
fn run<T: Transcript>(
transcript: &mut T,
_instance: &u32,
_witness: Witness<&()>,
) -> Result<u32, VerificationError> {
transcript.verifier_message_pow::<u32, Blake3PoW>(8.0)
}
}
let tag = b"example/v1/blake3-pow-8/u32";
let (proof, challenge) = Narg::prove::<PowRound>(tag, &0, &())?;
let replay = Narg::verify::<PowRound>(tag, &0, &proof)?;
assert_eq!(challenge, replay);Provided Methods§
Sourcefn verifier_message_pow<T, S>(
&mut self,
bits: f64,
) -> Result<T, VerificationError>where
T: FromUniform,
S: PowStrategy,
fn verifier_message_pow<T, S>(
&mut self,
bits: f64,
) -> Result<T, VerificationError>where
T: FromUniform,
S: PowStrategy,
Obtain a verifier message after a proof-of-work step using S.
Both the prover and verifier return Result<T, VerificationError>.
bits is the binary logarithm of the expected work, subject to the
chosen strategy’s supported range.
§Errors
The prover returns VerificationError if grinding exhausts the nonce
space. The verifier returns it if the nonce is invalid, the proof is
truncated, or an earlier read or check rejected the transcript.
§Panics
Either side may panic if the strategy rejects an unsupported difficulty.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".