pub struct PublicKey {
point: RistrettoPoint,
compressed: CompressedRistretto,
}Expand description
Public key - obtained using PublicKey::from_hex or PrivateKey::public_key.
Fields§
§point: RistrettoPoint§compressed: CompressedRistrettoImplementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn from_hex(hexstr: &str) -> Option<Self>
pub fn from_hex(hexstr: &str) -> Option<Self>
Turns a 64 digit hex string into a PublicKey.
Returns None when the hex-encoding is invalid or when the hex-encoding does not encode a
valid Ristretto point.
Sourcepub fn encrypt(&self, plaintext: RistrettoPoint) -> Triple
pub fn encrypt(&self, plaintext: RistrettoPoint) -> Triple
Encrypts the given plaintext for this public key.
If the plaintext is a random point, consider using Self::encrypt_random.
Sourcepub fn encrypt_with_random(
&self,
r: Scalar,
plaintext: RistrettoPoint,
) -> Triple
pub fn encrypt_with_random( &self, r: Scalar, plaintext: RistrettoPoint, ) -> Triple
Like Self::encrypt, but you can specify the random scalar used - which you shouldn’t
except to make deterministic tests.
Sourcepub fn encrypt_random(&self) -> Triple
pub fn encrypt_random(&self) -> Triple
Effectively encrypts a random plaintext for this public key.
Instead of picking random Ristretto point M and random scalar r and computing
(rB, r * pk + M, self)
we pick Ristretto points ek and ct randomly and return
(ek, ct, sekf).
since this is more efficient, and yields the same distribution.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PublicKey
impl<'de> Deserialize<'de> for PublicKey
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl Encoding<32> for PublicKey
impl Encoding<32> for PublicKey
Source§fn from_bytes(bytes: [u8; 32]) -> Option<PublicKey>
fn from_bytes(bytes: [u8; 32]) -> Option<PublicKey>
Some(object) from bytes if bytes encodes some object of type Self;
otherwise returns None.Source§fn from_slice(slice: &[u8]) -> Option<Self>
fn from_slice(slice: &[u8]) -> Option<Self>
[u8; N] from slice. Returns None if slice.len()!=N
or when the slice is not a valid encoding.Source§fn copy_to_slice(&self, slice: &mut [u8]) -> Option<()>
fn copy_to_slice(&self, slice: &mut [u8]) -> Option<()>
self into slice. Returns None when slice.len()!=N.Source§fn from_hex(hex: &str) -> Option<Self>
fn from_hex(hex: &str) -> Option<Self>
[u8; N] from the 2*N-digit hex string hex.
The case of the hex digits is ignored.Source§impl From<RistrettoPoint> for PublicKey
impl From<RistrettoPoint> for PublicKey
Source§fn from(point: RistrettoPoint) -> Self
fn from(point: RistrettoPoint) -> Self
Source§impl TryFrom<CompressedRistretto> for PublicKey
impl TryFrom<CompressedRistretto> for PublicKey
impl Eq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnsafeUnpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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