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

Builds a proof with provided nonces at default edge_bits

Builds a proof with all bytes zeroed out

Number of bytes required store a proof of given edge bits

Builds a proof with random POW data, needed so that tests that ignore POW don’t fail due to duplicate hashes

Returns the proof size

Pack the nonces of the proof to their exact bit size as described above

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Reads the data necessary to this Readable from the provided reader

Serialize this value into the given Serde serializer. Read more

Write the data held by this Writeable to the provided writer

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Obtain the hash of the object

Calls U::from(self).

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

Hash with a given index

Should always be Self

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)

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.