[−][src]Struct tari_crypto::ristretto::script_commitment::ScriptCommitmentFactory
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]
&self,
key: &RistrettoSecretKey,
value: u64,
script: &TariScript
) -> Result<ScriptCommitment, ScriptCommitmentError>
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]
&self,
k: &RistrettoSecretKey,
v: u64,
script: &TariScript,
commitment: &PedersenCommitment
) -> bool
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
impl RefUnwindSafe for ScriptCommitmentFactory
impl Send for ScriptCommitmentFactory
impl Sync for ScriptCommitmentFactory
impl Unpin for ScriptCommitmentFactory
impl UnwindSafe for ScriptCommitmentFactory
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> Cast<U> for T where
U: FromCast<T>,
U: FromCast<T>,
fn cast(self) -> U
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized,
[src]
T: InitializableFromZeroed + ?Sized,
impl<T> From<T> for T
[src]
impl<T> FromBits<T> for T
fn from_bits(t: T) -> T
impl<T> FromCast<T> for T
fn from_cast(t: T) -> T
impl<T> InitializableFromZeroed for T where
T: Default,
[src]
T: Default,
unsafe fn initialize(place: *mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> IntoBits<U> for T where
U: FromBits<T>,
U: FromBits<T>,
fn into_bits(self) -> U
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,