Enum simplicity::policy::Policy
source · pub enum Policy<Pk: SimplicityKey> {
Unsatisfiable(FailEntropy),
Trivial,
Key(Pk),
After(u32),
Older(u16),
Sha256(Pk::Sha256),
And {
left: Arc<Policy<Pk>>,
right: Arc<Policy<Pk>>,
},
Or {
left: Arc<Policy<Pk>>,
right: Arc<Policy<Pk>>,
},
Threshold(usize, Vec<Policy<Pk>>),
Assembly(Cmr),
}Expand description
Policy that expresses spending conditions for Simplicity.
The policy can be compiled into a Simplicity program and executed on the Bit Machine, given a witness.
Furthermore, the policy can be normalized and is amenable to semantic analysis.
Variants§
Unsatisfiable(FailEntropy)
Unsatisfiable
Trivial
Trivially satisfiable
Key(Pk)
Provide a signature that matches the given public key and some given message hash
After(u32)
Absolute timelock
Older(u16)
Relative timelock
Sha256(Pk::Sha256)
Provide the preimage of the given SHA256 hash image
And
Satisfy both of the given sub-policies
Or
Satisfy exactly one of the given sub-policies
Threshold(usize, Vec<Policy<Pk>>)
Satisfy exactly k of the given sub-policies
Assembly(Cmr)
Satisfy the program with the given CMR
Implementations§
source§impl<Pk: ToXOnlyPubkey> Policy<Pk>
impl<Pk: ToXOnlyPubkey> Policy<Pk>
source§impl<Pk: SimplicityKey> Policy<Pk>
impl<Pk: SimplicityKey> Policy<Pk>
sourcepub fn translate<T, Q, E>(&self, translator: &mut T) -> Result<Policy<Q>, E>where
T: Translator<Pk, Q, E>,
Q: SimplicityKey,
pub fn translate<T, Q, E>(&self, translator: &mut T) -> Result<Policy<Q>, E>where
T: Translator<Pk, Q, E>,
Q: SimplicityKey,
Convert a policy using one kind of public key to another type of public key
sourcepub fn normalized(self) -> Policy<Pk>
pub fn normalized(self) -> Policy<Pk>
Flatten out trees of Ands and Ors; eliminate Trivial and
Unsatisfiables. Does not reorder any branches; use .sort.
Trait Implementations§
source§impl<Pk: SimplicityKey> Debug for Policy<Pk>
impl<Pk: SimplicityKey> Debug for Policy<Pk>
source§impl<Pk: SimplicityKey> Display for Policy<Pk>
impl<Pk: SimplicityKey> Display for Policy<Pk>
source§impl<Pk: Ord + SimplicityKey> Ord for Policy<Pk>
impl<Pk: Ord + SimplicityKey> Ord for Policy<Pk>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<Pk: PartialEq + SimplicityKey> PartialEq for Policy<Pk>
impl<Pk: PartialEq + SimplicityKey> PartialEq for Policy<Pk>
source§impl<Pk: PartialOrd + SimplicityKey> PartialOrd for Policy<Pk>where
Pk::Sha256: PartialOrd,
impl<Pk: PartialOrd + SimplicityKey> PartialOrd for Policy<Pk>where
Pk::Sha256: PartialOrd,
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