[][src]Struct private_currency::crypto::Commitment

pub struct Commitment { /* fields omitted */ }

Pedersen commitment to an integer value.

Theory

A Pedersen commitment has the form (in the additive notation)

Comm(x; r) = xG + rH,

where

Q, G and H are public parameters of the scheme shared among all commitments, while x and r are private. (x, r) is called an opening to the commitment; knowing the opening, it’s easy to check if it corresponds to the given commitment.

Under common security assumptions, a Pedersen commitment is

Commitment arithmetic

It is possible to add and subtract Pedersen commitments; the result is a commitment to the sum / difference of corresponding values. This fact is what allows using commitments in private currency.

Implementation details

We use a Ristretto group built on top of Curve25519 as Q. Generators G and H are constructed according to the default scheme in the bulletproofs implementation.

Examples

let (mut commitment, mut opening) = Commitment::new(42);
assert_eq!(opening.value, 42);
assert_eq!(commitment, Commitment::from_opening(&opening));

let (other_commitment, other_opening) = Commitment::new(23);
commitment -= other_commitment;
opening -= other_opening;
assert_eq!(opening.value, 19);
assert_eq!(commitment, Commitment::from_opening(&opening));

Methods

impl Commitment
[src]

Creates a commitment with a randomly chosen blinding.

Return value

Returns the created commitment and the corresponding opening for it.

Creates a commitment from the given opening.

Creates a commitment with no blinding factor.

Warning. The commitments created in this way are not hiding. Use them only if you know what you’re doing.

Attempts to deserialize a commitment from byte slice.

Serializes this commitment to bytes.

Implementation details

The commitment is serialized as a single compressed Ristretto point (i.e., 32 bytes).

Verifies if this commitment corresponds to the provided opening.

Trait Implementations

impl Clone for Commitment
[src]

Performs copy-assignment from source. Read more

impl Eq for Commitment
[src]

impl PartialEq<Commitment> for Commitment
[src]

impl Debug for Commitment
[src]

impl Sub<Commitment> for Commitment
[src]

The resulting type after applying the - operator.

impl<'a, 'b> Sub<&'b Commitment> for &'a Commitment
[src]

The resulting type after applying the - operator.

impl Add<Commitment> for Commitment
[src]

The resulting type after applying the + operator.

impl<'a, 'b> Add<&'b Commitment> for &'a Commitment
[src]

The resulting type after applying the + operator.

impl SubAssign<Commitment> for Commitment
[src]

impl ExonumJson for Commitment
[src]

impl<'a> Field<'a> for Commitment
[src]

impl FromHex for Commitment
[src]

impl CryptoHash for Commitment
[src]

impl StorageValue for Commitment
[src]

Auto Trait Implementations

impl Send for Commitment

impl Sync for Commitment

Blanket Implementations

impl<T> From for T
[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

impl<'a, T> Field for T where
    T: SegmentField<'a>, 
[src]

impl<T> CryptoHash for T where
    T: Message
[src]

impl<T> UniqueHash for T where
    T: CryptoHash
[src]

impl<T> Erased for T

impl<T> Erased for T

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> Same for T

Should always be Self