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
impl Cmr
sourcepub fn update(self, left: Self, right: Self) -> Self
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
sourcepub fn update_1(self, right: Self) -> Self
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
sourcepub fn update_with_weight(self, left_weight: u64, right: Self) -> Self
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
pub fn update_fail_entropy(self, entropy: FailEntropy) -> Self
sourcepub fn from_byte_array(data: [u8; 32]) -> Self
pub fn from_byte_array(data: [u8; 32]) -> Self
Converts the given tagged hash into a byte array
sourcepub fn to_byte_array(self) -> [u8; 32]
pub fn to_byte_array(self) -> [u8; 32]
Converts the given tagged hash into a byte array
source§impl Cmr
impl Cmr
sourcepub fn disconnect(left: Cmr) -> Self
pub fn disconnect(left: Cmr) -> Self
Produce a CMR for a disconnect combinator
sourcepub fn fail(entropy: FailEntropy) -> Self
pub fn fail(entropy: FailEntropy) -> Self
Produce a CMR for a fail combinator
sourcepub fn const_word(v: &Value) -> Self
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.
Trait Implementations§
source§impl CoreConstructible for Cmr
impl CoreConstructible for Cmr
fn iden() -> Self
fn unit() -> Self
fn injl(child: &Self) -> Self
fn injr(child: &Self) -> Self
fn take(child: &Self) -> Self
fn drop_(child: &Self) -> Self
fn comp(left: &Self, right: &Self) -> Result<Self, Error>
fn case(left: &Self, right: &Self) -> Result<Self, Error>
fn assertl(left: &Self, right: Cmr) -> Result<Self, Error>
fn assertr(left: Cmr, right: &Self) -> Result<Self, Error>
fn pair(left: &Self, right: &Self) -> Result<Self, Error>
fn fail(entropy: FailEntropy) -> Self
fn const_word(word: Arc<Value>) -> Self
source§fn scribe(value: &Value) -> Self
fn scribe(value: &Value) -> Self
value as constant output. Read moresource§fn bit_false() -> Self
fn bit_false() -> Self
0 as constant output. Read moresource§fn bit_true() -> Self
fn bit_true() -> Self
1 as constant output. Read moresource§fn cond(left: &Self, right: &Self) -> Result<Self, Error>
fn cond(left: &Self, right: &Self) -> Result<Self, Error>
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 moresource§fn assert(child: &Self, hash: Cmr) -> Result<Self, Error>
fn assert(child: &Self, hash: Cmr) -> Result<Self, Error>
true, and fails otherwise.
The hash identifies the assertion and is returned upon failure. Read moresource§fn not(child: &Self) -> Result<Self, Error>
fn not(child: &Self) -> Result<Self, Error>
child. Read moresource§impl<X> DisconnectConstructible<X> for Cmr
impl<X> DisconnectConstructible<X> for Cmr
source§impl From<Cmr> for FirstPassImr
impl From<Cmr> for FirstPassImr
source§impl Ord for Cmr
impl Ord for Cmr
source§impl PartialOrd for Cmr
impl PartialOrd for Cmr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more