emerald-hwkey 0.5.0

Emerald HWKey - Harware Cryptocurrency Key Access
Documentation
= Emerald HWKey

image:https://github.com/emeraldpay/emerald-hwkey/workflows/Test/badge.svg["Test"]
image:https://coveralls.io/repos/github/emeraldpay/emerald-hwkey/badge.svg["Coveralls"]
image:https://codecov.io/gh/emeraldpay/emerald-hwkey/branch/master/graph/badge.svg[Codecov,link=https://codecov.io/gh/emeraldpay/emerald-hwkey]
image:https://img.shields.io/crates/v/emerald-hwkey.svg?style=flat-square["Crates",link="https://crates.io/crates/emerald-hwkey"]
image:https://img.shields.io/badge/License-Apache%202.0-blue.svg["License"]

Rust library to access Hardware Keys for Cryptocurrency.

.Supports:
- Ledger Nano S
- Ledger Nano X

== Development

=== Integration Testing with Speculos app

Get App Ledger App emulator from: https://github.com/LedgerHQ/speculos

The Speculos app is initialized with the following seed by default:
----
glory   promote mansion idle        axis    finger   extra   february
uncover one     trip    resource    lawn    turtle  enact   monster
seven   myth    punch   hobby       comfort wild    raise   skin
----

=== Test against a Bitcoin App

.Run it in docker as:
----
docker run --rm -it -p 5000:5000  speculos --display headless apps/btc.elf
----

.Run tests:
----
EMRLD_HWKEY_TEST=bitcoin cargo test --test speculos_bitcoin --features "speculos" -- --test-threads=1
----

=== Test against an Ethereum App

.Run Speculos Docker with NanoX app:
----
docker run --rm -it -v $(pwd)/testdata/ledger-elf:/speculos/apps -p 6000:5000  speculos --model nanox --display headless apps/ethereum-nanox-2.0.2-1.9.18.elf
----

.Run tests:
----
EMRLD_HWKEY_TEST=ethereum cargo test --test speculos_ethereum --features "speculos" -- --test-threads=1
----

=== Integration Testing with Real Hardware

For all the test the following Mnemonic Phrase is used:

----
blanket large   trumpet mandate call  great unhappy skull
special assist  draw    right   quote stone under   legend
invite  morning hub     believe pulp  piano tuition fruit
----

You can also verify addresses and get the actual Private Key by using https://iancoleman.io/bip39/#english with that
Mnemonic.
At least for the Ledger Nano products.

WARNING: Never transfer real money to the Test Ledger or any wallet created from the Mnemonic Phrase above.
         Since the Phrase is public all the money would be stolen immediately.


==== Ledger + No App

*No App* must be open on Ledger

----
EMRLD_HWKEY_TEST=ledger_noapp cargo test --test ledger_noapp -- --test-threads=1
----

==== Ledger + Bitcoin App

*Bitcoin App* must be open on Ledger

----
EMRLD_HWKEY_TEST=ledger_bitcoin cargo test --test ledger_bitcoin -- --test-threads=1
----


==== Ledger + Bitcoin Test App

*Bitcoin Test App* must be open on Ledger

----
EMRLD_HWKEY_TEST=ledger_bitcoin_test cargo test --test ledger_bitcoin -- --test-threads=1
----


==== Ledger + Ethereum App

*Ethereum App* must be open on Ledger

----
EMRLD_HWKEY_TEST=ledger_ethereum cargo test --test ledger_ethereum -- --test-threads=1
----

==== Ledger + Ethereum Classic App

*Ethereum Classic App* must be open on Ledger

----
EMRLD_HWKEY_TEST=ledger_ethereum_classic cargo test --test ledger_ethereum -- --test-threads=1
----

== License

Copyright 2022 EmeraldPay, Inc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.