Struct cosmian_crypto_core::Curve25519Secret

source ·
pub struct Curve25519Secret(/* private fields */);
Expand description

Secret from which the private keys are derived

Implementations§

source§

impl Curve25519Secret

Facades

Facades are used to hide the underlying types and provide a more user friendly interface to the user.

source

pub fn new<R: CryptoRngCore>(rng: &mut R) -> Self

Generate a random private key

This is a facade to RandomFixedSizeCBytes::new

source

pub fn as_bytes(&self) -> &[u8]

Get the underlying bytes slice of the private key

This is a facade to RandomFixedSizeCBytes::as_bytes

source

pub fn to_bytes(&self) -> [u8; 32]

Serialize the PrivateKey as a non zero scalar

This is a facade to <Self as FixedSizeCBytes>::to_bytes

source

pub fn try_from_bytes(bytes: [u8; 32]) -> Result<Self, CryptoCoreError>

Deserialize the PrivateKey from a non zero scalar

This is a facade to <Self as FixedSizeCBytes<CURVE_25519_SECRET_LENGTH>>::try_from_bytes

source§

impl Curve25519Secret

source

pub fn from_ed25519_private_key(sk: &Ed25519PrivateKey) -> Self

Convert the ED25519 private key to an X25519 private key

This method is useful when an Ed25519 public key has been converted to an X25519 public key. It will generate the private key that corresponds to the generated X25519 public key from the original private key.

See [X25519PublicKey::from_ed25519_public_key] for more details.

Trait Implementations§

source§

impl Clone for Curve25519Secret

source§

fn clone(&self) -> Curve25519Secret

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Curve25519Secret

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Curve25519Secret

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl FixedSizeCBytes<{ CURVE_25519_SECRET_LENGTH }> for Curve25519Secret

source§

fn to_bytes(&self) -> [u8; 32]

Converts the given key into an array of LENGTH bytes.
source§

fn try_from_bytes(bytes: [u8; 32]) -> Result<Self, CryptoCoreError>

Tries to create a key from the given array of bytes into a key.
source§

const LENGTH: usize = LENGTH

Key length.
source§

fn try_from_slice(slice: &[u8]) -> Result<Self, CryptoCoreError>

Tries to create a key from the given slice of bytes into a key.
source§

impl From<&Curve25519Secret> for X25519PrivateKey

source§

fn from(sk: &Ed25519PrivateKey) -> Self

Converts to this type from the input type.
source§

impl From<&Curve25519Secret> for Ed25519PublicKey

source§

fn from(sk: &Ed25519PrivateKey) -> Self

Converts to this type from the input type.
source§

impl From<&Curve25519Secret> for X25519CurvePoint

source§

fn from(sk: &X25519PrivateKey) -> Self

Converts to this type from the input type.
source§

impl Hash for Curve25519Secret

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Curve25519Secret

source§

fn eq(&self, other: &Curve25519Secret) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RandomFixedSizeCBytes<{ CURVE_25519_SECRET_LENGTH }> for Curve25519Secret

source§

fn new<R: CryptoRngCore>(rng: &mut R) -> Self

Generates a new random array of LENGTH bytes
source§

fn as_bytes(&self) -> &[u8]

Returns a slice over the array bytes.
source§

impl Serializable for Curve25519Secret

Key Serialization framework

§

type Error = CryptoCoreError

Error type returned by the serialization.
source§

fn length(&self) -> usize

Retrieves the length of the serialized object if it can be known. Read more
source§

fn write(&self, ser: &mut Serializer) -> Result<usize, Self::Error>

Writes to the given Serializer.
source§

fn read(de: &mut Deserializer<'_>) -> Result<Self, Self::Error>

Reads from the given Deserializer.
source§

fn serialize(&self) -> Result<Zeroizing<Vec<u8>>, Self::Error>

Serializes the object. Allocates the correct capacity if it is known.
source§

fn deserialize(bytes: &[u8]) -> Result<Self, Self::Error>

Deserializes the object.
source§

impl TryFrom<&Curve25519Secret> for Cached25519Signer

§

type Error = CryptoCoreError

The type returned in the event of a conversion error.
source§

fn try_from(sk: &Ed25519PrivateKey) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Zeroize for Curve25519Secret

source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
source§

impl CBytes for Curve25519Secret

source§

impl Eq for Curve25519Secret

source§

impl SecretCBytes<{ CURVE_25519_SECRET_LENGTH }> for Curve25519Secret

source§

impl StructuralPartialEq for Curve25519Secret

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<S, T> SignerMut<S> for T
where T: Signer<S>,

source§

fn try_sign(&mut self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
source§

fn sign(&mut self, msg: &[u8]) -> S

Sign the given message, update the state, and return a digital signature.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V