Skip to main content

Cv

Struct Cv 

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

The chaining value of a whole subtree, with its place: 2^level chunks (1024 bytes each), the index-th subtree of that size in the message. It is the only kind a left child can be.

A chaining value is the 32 bytes a BLAKE3 tree passes from a subtree up to its parent. It is not a hash of anything a program can check alone, and has its own type so that it is never taken for one: the root alone gives a Hash (TreeHasher::root_hash).

Equality compares the place and, in constant time, the bytes. Debug shows the place alone, so that a refusal’s message carries no chaining value of a keyed tree.

§Trait implementations

  • Clone reproduces both the value and its place, including an unset slot.
  • Copy copies the bytes and place together.
  • Debug shows the place or the unset state without exposing chaining bytes.
  • Eq identifies values with equal bytes and place.
  • PartialEq compares the place and compares the chaining bytes in constant time.

Implementations§

Source§

impl Cv

Source

pub const fn unset() -> Cv

A slot not yet filled, for an array that a call will fill: every call that takes a Cv as a subtree’s value refuses it (as_bytes gives its 32 zero bytes). Zeroed memory is the same value.

Source

pub const fn at(level: u32, index: u64, bytes: [u8; 32]) -> Cv

A chaining value a program stored or received, for the whole subtree at level and index. The place is the program’s word: bytes of another subtree give a wrong hash, as wrong input does.

Requires a level of at most 53 and a subtree that ends within a message’s 2^64 - 1 bytes.

Source

pub const fn as_bytes(&self) -> &[u8; 32]

The chaining value’s bytes.

Source

pub const fn level(&self) -> u32

The subtree holds 2^level chunks.

Requires a value that was set.

Source

pub const fn index(&self) -> u64

The subtree is the index-th of its size.

Requires a value that was set.

Trait Implementations§

Source§

impl Clone for Cv

Source§

fn clone(&self) -> Cv

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 Cv

Source§

impl Debug for Cv

Source§

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

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

impl Eq for Cv

Source§

impl From<Cv> for LastCv

A whole subtree that ends the message: the program says so.

Source§

fn from(cv: Cv) -> LastCv

Converts to this type from the input type.
Source§

impl PartialEq for Cv

Source§

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

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

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Freeze for Cv

§

impl RefUnwindSafe for Cv

§

impl Send for Cv

§

impl Sync for Cv

§

impl Unpin for Cv

§

impl UnsafeUnpin for Cv

§

impl UnwindSafe for Cv

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.