[][src]Struct tari_crypto::ristretto::script_commitment::ScriptCommitmentFactory

pub struct ScriptCommitmentFactory { /* fields omitted */ }

A factory for generating script commitments. The default PedersenCommitmentFactory is used by default.

Example

To create a script commitment factory, generate the corresponding pedersen commitment and attest that the original data opens the commitment:

    common::Blake256,
    keys::SecretKey,
    ristretto::script_commitment::ScriptCommitmentFactory,
    script::TariScript,
};

let mut rng = rand::thread_rng();
let k = RistrettoSecretKey::random(&mut rng);
let scf = ScriptCommitmentFactory::default();
let value = rng.next_u64();
let script = TariScript::default();
let sc = scf.commit_script::<Blake256>(&k, value, &script).unwrap();
let c = scf.script_to_pedersen(&sc);
assert!(scf.open_script::<Blake256>(&k, value, &script, &c));

Implementations

impl ScriptCommitmentFactory[src]

pub fn commit_script<D: Digest>(
    &self,
    key: &RistrettoSecretKey,
    value: u64,
    script: &TariScript
) -> Result<ScriptCommitment, ScriptCommitmentError>
[src]

Create a new script commitment form the given blinding factor (key), value and Tari script instance, using the generators of this factory.

pub fn script_to_pedersen(&self, sc: &ScriptCommitment) -> PedersenCommitment[src]

Return the adjusted Pedersen commitment associated with this ScriptCommitment, i.e. C = C + H(C||s).G

pub fn open_script<D: Digest>(
    &self,
    k: &RistrettoSecretKey,
    v: u64,
    script: &TariScript,
    commitment: &PedersenCommitment
) -> bool
[src]

Test whether the given private key, value and script open the given commitment

Trait Implementations

impl Default for ScriptCommitmentFactory[src]

Return a script commitment factory using the default generators, G, and the first NUMS value for H.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> Cast<U> for T where
    U: FromCast<T>, 

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> FromBits<T> for T

impl<T> FromCast<T> for T

impl<T> InitializableFromZeroed for T where
    T: Default
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> IntoBits<U> for T where
    U: FromBits<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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