Struct simplicity::Cmr

source ·
pub struct Cmr(/* private fields */);
Expand description

Commitment Merkle root

A Merkle root that commits to a node’s combinator and recursively its children.

Importantly, witness data and right disconnect branches are not included in the hash. This makes these elements malleable while preserving program identity (SegWit, delegation).

Uniquely identifies a program’s structure in terms of combinators at commitment time.

Implementations§

source§

impl Cmr

source

pub fn update(self, left: Self, right: Self) -> Self

Extend the given tagged hash by the given left and right hashes.

The hash self is taken as initial value, left and right hash are combined to create a 512-bit block, and the compression function is run once

source

pub fn update_1(self, right: Self) -> Self

Extend the given tagged hash by 256 bits of zeroes and the right hash.

The hash self is taken as initial value, 256 bits of zeroes and right hash are combined to create a 512-bit block, and the compression function is run once

source

pub fn update_with_weight(self, left_weight: u64, right: Self) -> Self

Updates the given tagged hash with given left cost and right hash.

The cost is serialized as the last 64 bits in the left block

source

pub fn update_fail_entropy(self, entropy: FailEntropy) -> Self

source

pub fn from_byte_array(data: [u8; 32]) -> Self

Converts the given tagged hash into a byte array

source

pub fn to_byte_array(self) -> [u8; 32]

Converts the given tagged hash into a byte array

source§

impl Cmr

source

pub const fn iden() -> Self

Produce a CMR for an iden combinator

source

pub const fn unit() -> Self

Produce a CMR for a unit combinator

source

pub fn injl(child: Cmr) -> Self

Produce a CMR for an injl combinator

source

pub fn injr(child: Cmr) -> Self

Produce a CMR for an injr combinator

source

pub fn take(child: Cmr) -> Self

Produce a CMR for a take combinator

source

pub fn drop(child: Cmr) -> Self

Produce a CMR for a drop combinator

source

pub fn comp(left: Cmr, right: Cmr) -> Self

Produce a CMR for a comp combinator

source

pub fn case(left: Cmr, right: Cmr) -> Self

Produce a CMR for a case combinator

source

pub fn pair(left: Cmr, right: Cmr) -> Self

Produce a CMR for a pair combinator

source

pub fn disconnect(left: Cmr) -> Self

Produce a CMR for a disconnect combinator

source

pub fn witness() -> Self

Produce a CMR for a witness combinator

source

pub fn fail(entropy: FailEntropy) -> Self

Produce a CMR for a fail combinator

source

pub fn jet<J: Jet>(jet: J) -> Self

Produce a CMR for a jet

source

pub fn const_word(v: &Value) -> Self

Compute the CMR of a constant word jet

This is equal to the IMR of the equivalent scribe, converted to a CMR in the usual way for jets.

source

pub const BITS: [Cmr; 2] = _

CMRs for the bits 0 and 1 – injl(unit) and injr(unit) respectively

Trait Implementations§

source§

impl AsRef<[u8]> for Cmr

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Cmr

source§

fn clone(&self) -> Cmr

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl CoreConstructible for Cmr

source§

fn iden() -> Self

source§

fn unit() -> Self

source§

fn injl(child: &Self) -> Self

source§

fn injr(child: &Self) -> Self

source§

fn take(child: &Self) -> Self

source§

fn drop_(child: &Self) -> Self

source§

fn comp(left: &Self, right: &Self) -> Result<Self, Error>

source§

fn case(left: &Self, right: &Self) -> Result<Self, Error>

source§

fn assertl(left: &Self, right: Cmr) -> Result<Self, Error>

source§

fn assertr(left: Cmr, right: &Self) -> Result<Self, Error>

source§

fn pair(left: &Self, right: &Self) -> Result<Self, Error>

source§

fn fail(entropy: FailEntropy) -> Self

source§

fn const_word(word: Arc<Value>) -> Self

source§

fn scribe(value: &Value) -> Self

Create a DAG that takes any input and returns value as constant output. Read more
source§

fn bit_false() -> Self

Create a DAG that takes any input and returns bit 0 as constant output. Read more
source§

fn bit_true() -> Self

Create a DAG that takes any input and returns bit 1 as constant output. Read more
source§

fn cond(left: &Self, right: &Self) -> Result<Self, Error>

Create a DAG that takes a bit and an input, such that the left child is evaluated on the input if the bit is 1 (if branch) and the right child is evaluated on the input otherwise (else branch). Read more
source§

fn assert(child: &Self, hash: Cmr) -> Result<Self, Error>

Create a DAG that asserts that its child returns true, and fails otherwise. The hash identifies the assertion and is returned upon failure. Read more
source§

fn not(child: &Self) -> Result<Self, Error>

Create a DAG that computes Boolean NOT of the child. Read more
source§

fn and(left: &Self, right: &Self) -> Result<Self, Error>

Create a DAG that computes Boolean AND of the left and right child. Read more
source§

fn or(left: &Self, right: &Self) -> Result<Self, Error>

Create a DAG that computes Boolean OR of the left and right. Read more
source§

impl Debug for Cmr

source§

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

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

impl<X> DisconnectConstructible<X> for Cmr

source§

fn disconnect(left: &Self, _right: &X) -> Result<Self, Error>

source§

impl Display for Cmr

source§

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

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

impl From<Cmr> for Amr

source§

fn from(cmr: Cmr) -> Self

Converts to this type from the input type.
source§

impl From<Cmr> for FirstPassImr

source§

fn from(cmr: Cmr) -> Self

Converts to this type from the input type.
source§

impl From<Cmr> for Imr

source§

fn from(cmr: Cmr) -> Self

Converts to this type from the input type.
source§

impl From<Tmr> for Cmr

source§

fn from(tmr: Tmr) -> Self

Converts to this type from the input type.
source§

impl FromStr for Cmr

§

type Err = HexToArrayError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Cmr

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<J: Jet> JetConstructible<J> for Cmr

source§

fn jet(jet: J) -> Self

source§

impl Ord for Cmr

source§

fn cmp(&self, other: &Cmr) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Cmr

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Cmr

source§

fn partial_cmp(&self, other: &Cmr) -> Option<Ordering>

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

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 · source§

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
1.0.0 · source§

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

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

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

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

impl<W> WitnessConstructible<W> for Cmr

source§

fn witness(_witness: W) -> Self

source§

impl Copy for Cmr

source§

impl Eq for Cmr

source§

impl StructuralPartialEq for Cmr

Auto Trait Implementations§

§

impl RefUnwindSafe for Cmr

§

impl Send for Cmr

§

impl Sync for Cmr

§

impl Unpin for Cmr

§

impl UnwindSafe for Cmr

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<J, X, W, T> Constructible<J, X, W> for T

source§

fn from_inner(inner: Inner<&Self, J, &X, W>) -> Result<Self, Error>

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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V