[−][src]Struct clarity::private_key::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]
impl PrivateKey
pub fn new() -> PrivateKey
[src]
pub fn new() -> PrivateKey
Creates a null private key that uses zeros.
pub fn from_slice(slice: &[u8]) -> Result<PrivateKey, Error>
[src]
pub fn from_slice(slice: &[u8]) -> Result<PrivateKey, Error>
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.
pub fn to_bytes(&self) -> [u8; 32]
[src]
pub fn to_bytes(&self) -> [u8; 32]
Get bytes back from a PrivateKey
pub fn to_public_key(&self) -> Result<Address, Error>
[src]
pub fn to_public_key(&self) -> Result<Address, Error>
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();
pub fn sign_hash(&self, data: &[u8]) -> Signature
[src]
pub fn sign_hash(&self, data: &[u8]) -> Signature
Signs any message that is represented by a data buffer
pub fn sign_msg(&self, data: &[u8]) -> Signature
[src]
pub fn sign_msg(&self, data: &[u8]) -> Signature
Signs a message. This makes a hash of data, and then makes prepares a signature of it.
Trait Implementations
impl Clone for PrivateKey
[src]
impl Clone for PrivateKey
fn clone(&self) -> PrivateKey
[src]
fn clone(&self) -> PrivateKey
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for PrivateKey
[src]
impl Copy for PrivateKey
impl From<[u8; 32]> for PrivateKey
[src]
impl From<[u8; 32]> for PrivateKey
impl ToString for PrivateKey
[src]
impl ToString for PrivateKey
impl PartialEq<PrivateKey> for PrivateKey
[src]
impl PartialEq<PrivateKey> for PrivateKey
fn eq(&self, other: &PrivateKey) -> bool
[src]
fn eq(&self, other: &PrivateKey) -> bool
fn ne(&self, other: &PrivateKey) -> bool
[src]
fn ne(&self, other: &PrivateKey) -> bool
impl Debug for PrivateKey
[src]
impl Debug for PrivateKey
impl FromStr for PrivateKey
[src]
impl FromStr for PrivateKey
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
fn from_str(s: &str) -> Result<Self, Self::Err>
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 Send for PrivateKey
impl Sync for PrivateKey
impl Sync for PrivateKey
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self