[][src]Struct elgamal_curve25519::PrivateKey

pub struct PrivateKey(_);

PrivateKey is an ElGamal private key. It's just a wrapper around Scalar. The key is just an integer between 1 and q-1, where q is the order of the group G.

Methods

impl PrivateKey[src]

pub fn new() -> Result<PrivateKey, String>[src]

new creates a new random PrivateKey.

pub fn random() -> Result<PrivateKey, String>[src]

random creates a random PrivateKey.

pub fn from_rng<R>(rng: &mut R) -> Result<PrivateKey, String> where
    R: RngCore + CryptoRng
[src]

from_rng creates a new random PrivateKey, but requires to specify a random generator.

pub fn from_hash<D>(digest: D) -> PrivateKey where
    D: Digest<OutputSize = U64>, 
[src]

from_hash creates a new PrivateKey from a 64 bytes hash.

pub fn from_scalar(scalar: Scalar) -> Result<PrivateKey, String>[src]

from_scalar creates a new PrivateKey from a Scalar. The Scalar value cannot be 0.

pub fn to_scalar(&self) -> Scalar[src]

to_scalar returns the inner Scalar of the PrivateKey.

pub fn from_bytes(buf: [u8; 32]) -> Result<PrivateKey, String>[src]

from_bytes creates a new PrivateKey from a slice of bytes.

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

to_bytes returns the PrivateKey as an array of bytes.

pub fn to_public(&self) -> PublicKey[src]

to_public returns the PublicKey of the PrivateKey.

Trait Implementations

impl PartialEq<PrivateKey> for PrivateKey[src]

impl Clone for PrivateKey[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Eq for PrivateKey[src]

impl Copy for PrivateKey[src]

impl Debug for PrivateKey[src]

impl Add<PrivateKey> for PrivateKey[src]

type Output = Option<PrivateKey>

The resulting type after applying the + operator.

impl Mul<PrivateKey> for Message[src]

type Output = Option<Message>

The resulting type after applying the * operator.

impl Mul<PrivateKey> for PublicKey[src]

type Output = Option<PublicKey>

The resulting type after applying the * operator.

Auto Trait Implementations

impl Send for PrivateKey

impl Sync for PrivateKey

Blanket Implementations

impl<T> From<T> for T[src]

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

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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

impl<T> Same<T> for T[src]

type Output = T

Should always be Self