pub struct SecretPoint<E: Curve>(/* private fields */);Expand description
Point representing sensitive information (like a derived secret)
Secret point should be treated with an extra care. You shouldn’t do any
branching (e.g. Eq, Ord) on the secret to avoid timing side-channel
attacks, so it implements only constant time traits (like ConstantTimeEq).
Also, when alloc feature is enabled, we enforce extra measures:
- Secret point leaves no trace in RAM after it’s dropped
Memory is zeroized after use - All clones of a secret point refer to the same region in the memory
I.e. there will always be only one instance of the point in the memory no matter how many clones you make
All these guarantees can be bypassed by calling .as_ref() and obtaining
&Point<E> that is not protected from timing attacks, leaving traces in
the memory, etc.
Implementations§
Source§impl<E: Curve> SecretPoint<E>
impl<E: Curve> SecretPoint<E>
Sourcepub fn new(point: &mut Point<E>) -> Self
pub fn new(point: &mut Point<E>) -> Self
Constructs a new secret point
Takes the original point by mutable reference instead of taking by value to avoid leaving copies of the point on stack. Point behind the reference will be zeroized after the function has returned.
Sourcepub fn as_nonsecret(&self) -> &Point<E>
pub fn as_nonsecret(&self) -> &Point<E>
Obtain the reference to the point, which you can use for any operations necessary. This bypasses all the secrecy guarantees, so be careful when handling the resulting value; ideally this reference should not be held for longer than one expression
The AsRef impl uses this method under the hood, and is provided as a
less explicit but very convenient alternative
Sourcepub fn to_bytes(&self, compressed: bool) -> EncodedSecretPoint<E>
pub fn to_bytes(&self, compressed: bool) -> EncodedSecretPoint<E>
Encodes a point as bytes
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, InvalidPoint>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, InvalidPoint>
Decodes a point from bytes
Trait Implementations§
Source§impl<E: Curve> Add<&NonZero<SecretPoint<E>>> for SecretPoint<E>
impl<E: Curve> Add<&NonZero<SecretPoint<E>>> for SecretPoint<E>
Source§impl<E: Curve> Add<&NonZero<SecretPoint<E>>> for &SecretPoint<E>
impl<E: Curve> Add<&NonZero<SecretPoint<E>>> for &SecretPoint<E>
Source§impl<E: Curve> Add<&SecretPoint<E>> for NonZero<SecretPoint<E>>
impl<E: Curve> Add<&SecretPoint<E>> for NonZero<SecretPoint<E>>
Source§impl<E: Curve> Add<&SecretPoint<E>> for &NonZero<SecretPoint<E>>
impl<E: Curve> Add<&SecretPoint<E>> for &NonZero<SecretPoint<E>>
Source§impl<E: Curve> Add<NonZero<SecretPoint<E>>> for SecretPoint<E>
impl<E: Curve> Add<NonZero<SecretPoint<E>>> for SecretPoint<E>
Source§impl<E: Curve> Add<NonZero<SecretPoint<E>>> for &SecretPoint<E>
impl<E: Curve> Add<NonZero<SecretPoint<E>>> for &SecretPoint<E>
Source§impl<E: Curve> Add<SecretPoint<E>> for NonZero<SecretPoint<E>>
impl<E: Curve> Add<SecretPoint<E>> for NonZero<SecretPoint<E>>
Source§impl<E: Curve> Add<SecretPoint<E>> for &NonZero<SecretPoint<E>>
impl<E: Curve> Add<SecretPoint<E>> for &NonZero<SecretPoint<E>>
Source§impl<E: Curve> AddAssign<&SecretPoint<E>> for Point<E>
impl<E: Curve> AddAssign<&SecretPoint<E>> for Point<E>
Source§fn add_assign(&mut self, rhs: &SecretPoint<E>)
fn add_assign(&mut self, rhs: &SecretPoint<E>)
+= operation. Read moreSource§impl<E: Curve> AddAssign<SecretPoint<E>> for Point<E>
impl<E: Curve> AddAssign<SecretPoint<E>> for Point<E>
Source§fn add_assign(&mut self, rhs: SecretPoint<E>)
fn add_assign(&mut self, rhs: SecretPoint<E>)
+= operation. Read moreSource§impl<E: Curve> Clone for SecretPoint<E>
impl<E: Curve> Clone for SecretPoint<E>
Source§impl<E: Curve> ConstantTimeEq for SecretPoint<E>
impl<E: Curve> ConstantTimeEq for SecretPoint<E>
Source§impl<E: Curve> Debug for SecretPoint<E>
impl<E: Curve> Debug for SecretPoint<E>
Source§impl<'de, E: Curve> Deserialize<'de> for SecretPoint<E>
Available on crate feature serde only.
impl<'de, E: Curve> Deserialize<'de> for SecretPoint<E>
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'de, E: Curve> DeserializeAs<'de, SecretPoint<E>> for Compact
Available on crate feature serde only.
impl<'de, E: Curve> DeserializeAs<'de, SecretPoint<E>> for Compact
serde only.Source§fn deserialize_as<D>(deserializer: D) -> Result<SecretPoint<E>, D::Error>where
D: Deserializer<'de>,
fn deserialize_as<D>(deserializer: D) -> Result<SecretPoint<E>, D::Error>where
D: Deserializer<'de>,
Source§impl<E: Curve> From<NonZero<SecretPoint<E>>> for SecretPoint<E>
impl<E: Curve> From<NonZero<SecretPoint<E>>> for SecretPoint<E>
Source§fn from(secret_point: NonZero<SecretPoint<E>>) -> Self
fn from(secret_point: NonZero<SecretPoint<E>>) -> Self
Source§impl<E: Curve> Serialize for SecretPoint<E>
Available on crate feature serde only.
impl<E: Curve> Serialize for SecretPoint<E>
serde only.Source§impl<E: Curve> SerializeAs<SecretPoint<E>> for Compact
Available on crate feature serde only.
impl<E: Curve> SerializeAs<SecretPoint<E>> for Compact
serde only.Source§fn serialize_as<S>(
source: &SecretPoint<E>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize_as<S>(
source: &SecretPoint<E>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
Source§impl<E: Curve> Sub<&NonZero<SecretPoint<E>>> for SecretPoint<E>
impl<E: Curve> Sub<&NonZero<SecretPoint<E>>> for SecretPoint<E>
Source§impl<E: Curve> Sub<&NonZero<SecretPoint<E>>> for &SecretPoint<E>
impl<E: Curve> Sub<&NonZero<SecretPoint<E>>> for &SecretPoint<E>
Source§impl<E: Curve> Sub<&SecretPoint<E>> for NonZero<SecretPoint<E>>
impl<E: Curve> Sub<&SecretPoint<E>> for NonZero<SecretPoint<E>>
Source§impl<E: Curve> Sub<&SecretPoint<E>> for &NonZero<SecretPoint<E>>
impl<E: Curve> Sub<&SecretPoint<E>> for &NonZero<SecretPoint<E>>
Source§impl<E: Curve> Sub<NonZero<SecretPoint<E>>> for SecretPoint<E>
impl<E: Curve> Sub<NonZero<SecretPoint<E>>> for SecretPoint<E>
Source§impl<E: Curve> Sub<NonZero<SecretPoint<E>>> for &SecretPoint<E>
impl<E: Curve> Sub<NonZero<SecretPoint<E>>> for &SecretPoint<E>
Source§impl<E: Curve> Sub<SecretPoint<E>> for NonZero<SecretPoint<E>>
impl<E: Curve> Sub<SecretPoint<E>> for NonZero<SecretPoint<E>>
Source§impl<E: Curve> Sub<SecretPoint<E>> for &NonZero<SecretPoint<E>>
impl<E: Curve> Sub<SecretPoint<E>> for &NonZero<SecretPoint<E>>
Source§impl<E: Curve> SubAssign<&SecretPoint<E>> for Point<E>
impl<E: Curve> SubAssign<&SecretPoint<E>> for Point<E>
Source§fn sub_assign(&mut self, rhs: &SecretPoint<E>)
fn sub_assign(&mut self, rhs: &SecretPoint<E>)
-= operation. Read moreSource§impl<E: Curve> SubAssign<SecretPoint<E>> for Point<E>
impl<E: Curve> SubAssign<SecretPoint<E>> for Point<E>
Source§fn sub_assign(&mut self, rhs: SecretPoint<E>)
fn sub_assign(&mut self, rhs: SecretPoint<E>)
-= operation. Read moreSource§impl<'s, E: Curve> Sum<&'s NonZero<SecretPoint<E>>> for SecretPoint<E>
impl<'s, E: Curve> Sum<&'s NonZero<SecretPoint<E>>> for SecretPoint<E>
Source§impl<'s, E: Curve> Sum<&'s SecretPoint<E>> for Point<E>
impl<'s, E: Curve> Sum<&'s SecretPoint<E>> for Point<E>
Source§fn sum<I: Iterator<Item = &'s SecretPoint<E>>>(iter: I) -> Self
fn sum<I: Iterator<Item = &'s SecretPoint<E>>>(iter: I) -> Self
Self from the elements by “summing up”
the items.