[][src]Struct clarity::private_key::PrivateKey

pub struct PrivateKey(_);

Representation of an Ethereum private key.

Private key can be created using a textual representation, a raw binary form using array of bytes.

With PrivateKey you are able to sign messages, derive public keys. Cryptography-related methods use SECP256K1 elliptic curves.

Methods

impl PrivateKey
[src]

Creates a null private key that uses zeros.

Convert a given slice of bytes into a valid private key.

Input bytes are validated for a length only.

  • slice - A slice of raw bytes with a length of 32.

Get bytes back from a PrivateKey

Create a public key for a given private key.

This is well explained in the Ethereum Yellow Paper Appendix F.

Examples

use clarity::PrivateKey;
let private_key : PrivateKey = "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f1e".parse().unwrap();
let public_key = private_key.to_public_key().unwrap();

Signs any message that is represented by a data buffer

Signs a message. This makes a hash of data, and then makes prepares a signature of it.

Trait Implementations

impl ToString for PrivateKey
[src]

Converts PrivateKey into a textual representation.

impl PartialEq<PrivateKey> for PrivateKey
[src]

impl From<[u8; 32]> for PrivateKey
[src]

impl Clone for PrivateKey
[src]

Performs copy-assignment from source. Read more

impl Copy for PrivateKey
[src]

impl Debug for PrivateKey
[src]

impl FromStr for PrivateKey
[src]

The associated error which can be returned from parsing.

Parse a textual representation of a private key back into PrivateKey type.

It has to be a string that represents 64 characters that are hexadecimal representation of 32 bytes. Optionally this string can be prefixed with 0x at the beggining.

Auto Trait Implementations

impl Send for PrivateKey

impl Sync for PrivateKey

Blanket Implementations

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T
[src]

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

impl<T> Same for T

Should always be Self