Skip to main content

FusedPowConfig

Struct FusedPowConfig 

Source
pub struct FusedPowConfig { /* private fields */ }
Expand description

A configuration for proof of work on the transcript sponge.

For bits > 0:

  1. The prover sends the least passing nonce n < 2^(bits + 7) as canonical unsigned LEB128.
  2. The verifier checks the nonce encoding and range. Both parties absorb the nonce and squeeze ceil(bits / 8) check bytes. The verifier rejects unless their low bits bits, read little-endian, are zero.
  3. Both parties derive the verifier message from the following sponge output via Transcript::verifier_message.

At zero difficulty, both parties derive the verifier message directly.

§Security

For fresh, independent uniform sponge output, the check passes with probability 2^-bits. The bytes after the check remain uniform. The soundness benefit depends on the protocol, sponge and challenge decoding. The difficulty, placement of this step and verifier-message type must be fixed by the protocol and bound in the session identifier.

§Performance

The default helper searches sequentially on the calling thread. On a ProverState whose public sponge is Send, verifier_message_pow_parallel (feature parallel) searches on the Rayon pool and writes the same proof. With a permutation-backed sponge, when the nonce, the check bytes and the returned message fit in one rate block, a search trial costs about one permutation.

§Errors

The prover returns VerificationError if:

  • The search exhausts the nonce space.
  • At positive difficulty, a custom transcript provides no Transcript::verifier_message_oracle.
  • The live transcript rejects the nonce that passed the oracle check. The nonce has already been written, so discard the prover state.

The verifier returns an error if the nonce is truncated, noncanonical or out of range, if the check bits are nonzero, or if the transcript has already been rejected.

§Panics

Panics if bits > 57: the u64 nonce space must hold 2^(bits+7) values.

Implementations§

Source§

impl FusedPowConfig

Source

pub const fn new(bits: u32) -> Self

Configure fused PoW at a protocol-fixed difficulty, from 0 through 57.

§Panics

Panics if bits > 57.

Trait Implementations§

Source§

impl Clone for FusedPowConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FusedPowConfig

Source§

impl Debug for FusedPowConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for FusedPowConfig

Source§

impl PartialEq for FusedPowConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PowStrategy for FusedPowConfig

Source§

type Nonce = Leb128

The canonical, self-delimiting nonce codec. Integers use fixed-width encoding. Read more
Source§

fn enabled(&self) -> bool

Whether to exchange a nonce and derive check bytes. Read more
Source§

fn last_nonce(&self) -> u64

The inclusive nonce bound, starting at zero.
Source§

fn challenge_len(&self) -> usize

Number of verifier bytes derived after each candidate nonce. Read more
Source§

fn accepts(&self, _nonce: u64, challenge: &[u8]) -> bool

Test the nonce and its verifier bytes without changing the puzzle. Acceptance must not depend on evaluation order. challenge must contain exactly Self::challenge_len bytes. Read more
Source§

fn solve<E: Fn(&[u8], &mut [u8]) + Clone>(self, evaluate: E) -> Option<u64>

Return the least accepted nonce in 0..=last_nonce(), or None on exhaustion. Read more
Source§

fn solve_parallel<E>(self, evaluate: E) -> Option<u64>
where Self: Send, E: Fn(&[u8], &mut [u8]) + Clone + Send,

Return the same least nonce as Self::solve, or None on exhaustion. Read more
Source§

impl StructuralPartialEq for FusedPowConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.