Expand description
A Cuck(at)oo Cycle proof of work, consisting of the edge_bits to get the graph size (i.e. the 2-log of the number of edges) and the nonces of the graph solution. While being expressed as u64 for simplicity, nonces a.k.a. edge indices range from 0 to (1 << edge_bits) - 1
The hash of the Proof
is the hash of its packed nonces when serializing
them at their exact bit size. The resulting bit sequence is padded to be
byte-aligned. We form a PROOFSIZE*edge_bits integer by packing the PROOFSIZE edge
indices together, with edge index i occupying bits i * edge_bits through
(i+1) * edge_bits - 1, padding it with up to 7 0-bits to a multiple of 8 bits,
writing as a little endian byte array, and hashing with blake2b using 256 bit digest.
Fields
edge_bits: u8
Power of 2 used for the size of the cuckoo graph
nonces: Vec<u64>
The nonces
Implementations
sourceimpl Proof
impl Proof
sourcepub fn new(in_nonces: Vec<u64>) -> Proof
pub fn new(in_nonces: Vec<u64>) -> Proof
Builds a proof with provided nonces at default edge_bits
sourcepub fn pack_len(bit_width: u8) -> usize
pub fn pack_len(bit_width: u8) -> usize
Number of bytes required store a proof of given edge bits
sourcepub fn random(proof_size: usize) -> Proof
pub fn random(proof_size: usize) -> Proof
Builds a proof with random POW data, needed so that tests that ignore POW don’t fail due to duplicate hashes
sourcepub fn proof_size(&self) -> usize
pub fn proof_size(&self) -> usize
Returns the proof size
Trait Implementations
sourceimpl PartialOrd<Proof> for Proof
impl PartialOrd<Proof> for Proof
sourcefn partial_cmp(&self, other: &Proof) -> Option<Ordering>
fn partial_cmp(&self, other: &Proof) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl DefaultHashable for Proof
impl Eq for Proof
impl StructuralPartialEq for Proof
Auto Trait Implementations
impl RefUnwindSafe for Proof
impl Send for Proof
impl Sync for Proof
impl Unpin for Proof
impl UnwindSafe for Proof
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> CloneAny for T where
T: Any + Clone,
impl<T> CloneAny for T where
T: Any + Clone,
fn clone_any(&self) -> Box<dyn CloneAny + 'static, Global>
fn clone_any_send(&self) -> Box<dyn CloneAny + Send + 'static, Global> where
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync + 'static, Global> where
T: Sync,
fn clone_any_send_sync(
&self
) -> Box<dyn CloneAny + Send + Sync + 'static, Global> where
T: Send + Sync,
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<D> Hashed for D where
D: DefaultHashable,
impl<D> Hashed for D where
D: DefaultHashable,
sourceimpl<T> PMMRIndexHashable for T where
T: DefaultHashable,
impl<T> PMMRIndexHashable for T where
T: DefaultHashable,
sourcefn hash_with_index(&self, index: u64) -> Hash
fn hash_with_index(&self, index: u64) -> Hash
Hash with a given index
sourceimpl<H> ShortIdentifiable for H where
H: Hashed,
impl<H> ShortIdentifiable for H where
H: Hashed,
sourcefn short_id(&self, hash: &Hash, nonce: u64) -> ShortId
fn short_id(&self, hash: &Hash, nonce: u64) -> ShortId
Generate a short_id via the following -
- extract k0/k1 from block_hash hashed with the nonce (first two u64
values) * initialize a siphasher24 with k0/k1
- self.hash() passing in the siphasher24 instance
- drop the 2 most significant bytes (to return a 6 byte short_id)
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more