pub struct Proof {
pub edge_bits: u8,
pub nonces: Vec<u64>,
}
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§
Source§impl 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
Sourcepub fn pack_nonces(&self) -> Vec<u8> ⓘ
pub fn pack_nonces(&self) -> Vec<u8> ⓘ
Pack the nonces of the proof to their exact bit size as described above
Trait Implementations§
Source§impl PartialOrd for Proof
impl PartialOrd for Proof
impl DefaultHashable for Proof
impl Eq for Proof
impl StructuralPartialEq for Proof
Auto Trait Implementations§
impl Freeze for Proof
impl RefUnwindSafe for Proof
impl Send for Proof
impl Sync for Proof
impl Unpin for Proof
impl UnwindSafe for Proof
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<D> Hashed for Dwhere
D: DefaultHashable,
impl<D> Hashed for Dwhere
D: DefaultHashable,
Source§impl<T> PMMRIndexHashable for Twhere
T: DefaultHashable,
impl<T> PMMRIndexHashable for Twhere
T: DefaultHashable,
Source§fn hash_with_index(&self, index: u64) -> Hash
fn hash_with_index(&self, index: u64) -> Hash
Source§impl<H> ShortIdentifiable for Hwhere
H: Hashed,
impl<H> ShortIdentifiable for Hwhere
H: Hashed,
Source§fn 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)