[][src]Struct ehsm::EHSMContext

pub struct EHSMContext { /* fields omitted */ }

Implementations

impl EHSMContext[src]

pub fn new<P>(filename: P) -> Result<EHSMContext, Error> where
    P: AsRef<Path>, 
[src]

Creates a new EHSMContext from the shared library name

Examples

    use ehsm::*;
    let lib_name = ehsm_library_name();
    let ehsm = EHSMContext::new(lib_name.as_path()).expect("Failed to load ehsm library functions");

pub fn has_bitcoin_key(
    &self,
    session: CK_SESSION_HANDLE,
    handle: CK_OBJECT_HANDLE_PTR
) -> Result<bool, Error>
[src]

Returns true if the device has a bitcoin key object. If it does have a key, the object handle is returned in handle.

pub fn import_bitcoin_key(
    &self,
    session: CK_SESSION_HANDLE,
    seed: &Vec<u8>
) -> Result<(), Error>
[src]

Import a bitcoin key from the provided binary seed

pub fn sign_bitcoin_hash(
    &self,
    session: CK_SESSION_HANDLE,
    hash: &Vec<u8>,
    indexes: &Vec<u32>
) -> Result<Vec<u8>, Error>
[src]

Sign the provided hash with the private key at the specified BIP32 path. The path is defined by the indexes provided.

Examples

    use ehsm::*;
    // empty index vector is the root key or "m"
    // for "m/0", just add 0 to indexes, i.e. indexes.push(0) etc. to build the BIP32 path
    let mut indexes: Vec<u32> = Vec::new();
    // let sig = ehsm.sign_bitcoin_hash(session,&vec![0;32],&indexes).expect("Failed to sign hash");

pub fn get_bitcoin_pub(
    &self,
    session: CK_SESSION_HANDLE,
    indexes: &Vec<u32>,
    net: u32
) -> Result<String, Error>
[src]

Get the BTC base58 encoded public key at the specified BIP32 path. The path is defined by the indexes provided.

Examples

    use ehsm::*;
    // empty index vector is the root key or "m"
    // for "m/0", just add 0 to indexes, i.e. indexes.push(0) etc. to build the BIP32 path
    let mut indexes: Vec<u32> = Vec::new();
    // main net
    let net: u32 = 0x0488B21Eu32;
    // let xpub = ehsm.get_bitcoin_pub(session, &indexes, net).expect("Failed to get btc pub");

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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.