pub enum PublicCommitment {
Open(Fr, G1Affine),
Closed(G1Affine),
}
Expand description
Use an enum to show that the commitments can be open, including the random value, or closed, which is secure.
Variants§
Open(Fr, G1Affine)
An Open commitment includes the random value, which is the [BlsFr] here. It should never be sent to an untrusted party, as they can get some knowledge of the original value with it.
Closed(G1Affine)
A Closed commitment is stripped of its random value and can safely be shared with untrusted parties.
Implementations§
Source§impl PublicCommitment
impl PublicCommitment
Sourcepub fn from_message(setup: &mut PublicSetup, message: &BlsFr) -> Self
pub fn from_message(setup: &mut PublicSetup, message: &BlsFr) -> Self
Create a new commitment from a scalar. This returns an Open commitment, including the random value.
Sourcepub fn close(self) -> Self
pub fn close(self) -> Self
Close this commitment by discarding the random value. For security, this consumes the PublicCommitment.
Sourcepub fn rand(&self) -> BlsFr
pub fn rand(&self) -> BlsFr
Returns the random value of this commitment. If the commitment is closed, it panics.
Sourcepub fn affine(&self) -> BlsG1Affine
pub fn affine(&self) -> BlsG1Affine
Returns the affine, public, value of this commitment, which is always available.
Sourcepub fn assert_closed(&self)
pub fn assert_closed(&self)
Make sure the commitment has been closed.
Trait Implementations§
Source§impl CanonicalSerialize for PublicCommitment
impl CanonicalSerialize for PublicCommitment
Source§fn serialize_with_mode<W: Write>(
&self,
writer: W,
mode: Compress,
) -> Result<(), SerializationError>
fn serialize_with_mode<W: Write>( &self, writer: W, mode: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, mode: Compress) -> usize
fn serialize_compressed<W>(&self, writer: W) -> Result<(), SerializationError>where
W: Write,
fn compressed_size(&self) -> usize
fn serialize_uncompressed<W>(&self, writer: W) -> Result<(), SerializationError>where
W: Write,
fn uncompressed_size(&self) -> usize
Source§impl Clone for PublicCommitment
impl Clone for PublicCommitment
Source§fn clone(&self) -> PublicCommitment
fn clone(&self) -> PublicCommitment
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for PublicCommitment
impl RefUnwindSafe for PublicCommitment
impl Send for PublicCommitment
impl Sync for PublicCommitment
impl Unpin for PublicCommitment
impl UnwindSafe for PublicCommitment
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CanonicalSerializeHashExt for Twhere
T: CanonicalSerialize,
impl<T> CanonicalSerializeHashExt for Twhere
T: CanonicalSerialize,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more