Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware wallet #43

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
a3d73b0
Setting up a skycoin_crypto tools project for hardware-wallet
mpsido Feb 11, 2018
a419e3e
Correcting typos in README.md
mpsido Feb 11, 2018
d46a1a0
Renaming test_genereate_deterministic_key_pair_seckey to test_generat…
mpsido Feb 11, 2018
b7cb929
Testing shared key generation (ECDH)
mpsido Feb 11, 2018
db90cc0
Fixing compilation steps: adding dependancy to libcheck was not perfe…
mpsido Feb 11, 2018
44c3cd9
Adding .gitignore
mpsido Feb 11, 2018
756b77b
Moving includes into source file
mpsido Feb 12, 2018
659719d
Add tohex function, and try different functions to compute ECDH
mpsido Feb 12, 2018
f201ff7
ECDH multipy succeeded !
mpsido Feb 22, 2018
de72db6
Improvements on sha256 computing syntax
mpsido Feb 22, 2018
f7abdf5
Making test_compute_ecdh pass
mpsido Feb 23, 2018
1465871
Moving the computation of ECDH shared secret into a ecdh_shared_secre…
mpsido Feb 23, 2018
02ba083
Create generate_pubkey_from_seckey function
mpsido Feb 24, 2018
bcf744d
genereate_deterministic_key_pair function
mpsido Feb 24, 2018
0c62366
Removing generate_deterministic_key_pair_seckey function, it is just …
mpsido Feb 24, 2018
8140eeb
Separating ecdh and ecdh + hash256
mpsido Feb 24, 2018
27743fa
Computing test_secp256k1Hash inside test
mpsido Feb 24, 2018
42f4e04
Moving secp256k1Hash into a standalone function
mpsido Feb 24, 2018
5637bfb
Adding few more test cases to test_secp256k1Hash
mpsido Feb 24, 2018
6f75c29
test_generate_deterministic_key_pair_iterator
mpsido Feb 24, 2018
b40b3c8
Move generate_deterministic_key_pair_iterator into a standalone function
mpsido Feb 24, 2018
98871f4
test_to_address_hash
mpsido Feb 24, 2018
da045f9
Compute base58 address
mpsido Feb 26, 2018
2d135df
Moving includes at their right place
mpsido Feb 26, 2018
5a87b00
Moving generate_base58_address_from_pubkey into a standalone function
mpsido Feb 26, 2018
a4ee143
Replace tabs by four spaces and correcting typos
mpsido Feb 28, 2018
f78caf3
generate_bitcoin_address_from_pubkey function
mpsido Mar 1, 2018
96abd79
generate_bitcoin_private_address_from_pubkey function
mpsido Mar 1, 2018
fb74a8f
Commit temporary not cleaned code for pubkey generation from signature
mpsido Mar 13, 2018
5d1c54e
Correcting recid, cleaning code and adding more tests in test_recover…
mpsido Mar 14, 2018
a95cd23
Correcting indent, writing 4 spaces instead of tab
mpsido Mar 15, 2018
3dff415
Making a dynamic library out of skycoin-crypto
mpsido Mar 21, 2018
e9b0a0a
Moving tohex function in skycoin_crypto.c
mpsido Mar 21, 2018
b5ebbd4
Readme file
mpsido Mar 21, 2018
45b3ebb
Renaming function generate_bitcoin_private_address_from_pubkey to gen…
mpsido Mar 22, 2018
9519675
Renaming function generate_bitcoin_private_address_from_pubkey to gen…
mpsido Mar 22, 2018
ddd00c6
Reading base58 inputs
mpsido Mar 23, 2018
83f4632
pass message as const pointer to recover_pubkey_from_signed_message f…
mpsido Mar 26, 2018
60b1c36
Creating API to communicate with trezor device
mpsido Apr 6, 2018
caed4f4
Moving usbhid adding wire for google protobuf and updating go import …
mpsido Apr 8, 2018
1928b10
Library usage example
mpsido Apr 8, 2018
b8bbd2c
First version of ecdsa_skycoin_sign that returns satisfying signature…
mpsido Apr 12, 2018
25eea87
adding nonce manual setting for test purposes
mpsido Apr 12, 2018
4c71932
Fixing the nounce problem
mpsido Apr 12, 2018
00c722d
removing commented out code in test_skycoin_crypto.c
mpsido Apr 12, 2018
0cf525f
recover_pubkey_from_signed_message in test_signature
mpsido Apr 13, 2018
b4381ec
write recey as last byte of signature inside ecdsa_skycoin_sign function
mpsido Apr 13, 2018
2675e35
test_signature with another key pair
mpsido Apr 13, 2018
1226fed
Remove by or recid from ecdsa_skycoin_sign parameters
mpsido Apr 13, 2018
6169cc0
clean ecdsa_skycoin_sign from logs and commented out code
mpsido Apr 13, 2018
fdf2081
Move request creation in a separate function
mpsido Apr 15, 2018
9506835
Adding function MessageCheckMessageSignature
mpsido Apr 15, 2018
0a29077
Adding message MessageSkycoinSignMessage
mpsido Apr 17, 2018
c7cc301
Moving files, everything related to firware had been moved in hardwar…
mpsido Apr 17, 2018
9e0f3a1
Copying trezor-mcu firmware
mpsido Apr 17, 2018
16394cb
removing visual studio workspace file from repo
mpsido Apr 21, 2018
c510f93
Changing skycoin-crypto, from a submodule it became a simple relative…
mpsido Apr 25, 2018
e2b3c19
get the next seed from generate_deterministic_key_pair_iterator function
mpsido Apr 25, 2018
298c912
Fixing broken link
mpsido Apr 25, 2018
112d9f3
Generate skycoin address using existing device seed. And modifying me…
mpsido Apr 25, 2018
49d4365
Adding function fsm_getKeyPairAtIndex and remove the code added in fs…
mpsido Apr 25, 2018
bc691cb
Adding README.md file for hardware-wallet
mpsido Apr 27, 2018
154dc40
moving README.md from skycoin-api to firmware and refer to trezor-mcu…
mpsido Apr 27, 2018
ef483db
Re-adding README.md file in skycoin-api folder
mpsido Apr 27, 2018
4a051d1
Update README.md
mpsido Apr 27, 2018
07b130d
Removing deprecated sentences from the README.md
mpsido Apr 27, 2018
fe1dc0c
Using address index in SkycoinSignMessage function
mpsido Apr 28, 2018
0d0bba2
Insert some randomness in signature
mpsido Apr 30, 2018
fb8cbde
Allow empty messages to be sent to device
mpsido May 1, 2018
b74243b
WipeDevice in main.go
mpsido May 2, 2018
a92a5ff
Fixing wipe device
mpsido May 2, 2018
9c6ec65
LoadDevice in main.go
mpsido May 2, 2018
4cfe691
Fixing next seed update in fsm_getKeyPairAtIndex
mpsido May 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions hardware-wallet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.o
test_skycoin_crypto
8 changes: 8 additions & 0 deletions hardware-wallet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This folder provides a firmware implementing skycoin features, and tools to test it.

The firmware it self is under [firmware](https://github.com/skycoin/services/tree/hardware-wallet/hardware-wallet/firmware) folder.
The firmware had been copied and modified from [this repository](https://github.com/trezor/trezor-mcu).

The [skycoin-api](https://github.com/skycoin/services/tree/hardware-wallet/hardware-wallet/skycoin-api) folder contains the definition of the functions implementing the skycoin features.

The [go-api-for-hardware-wallet](https://github.com/skycoin/services/tree/hardware-wallet/hardware-wallet/go-api-for-hardware-wallet) defines functions that act as code example to communicate with the firmware using a golang code.
14 changes: 14 additions & 0 deletions hardware-wallet/firmware/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.cache/
.vscode/
_attic/
build/
*.o
*.a
*.d
*.bin
*.elf
*.hex
*.img
*.list
*.srec
*.log
15 changes: 15 additions & 0 deletions hardware-wallet/firmware/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[submodule "trezor-crypto"]
path = vendor/trezor-crypto
url = https://github.com/trezor/trezor-crypto.git
[submodule "trezor-common"]
path = vendor/trezor-common
url = https://github.com/mpsido/trezor-common.git
[submodule "trezor-qrenc"]
path = vendor/trezor-qrenc
url = https://github.com/trezor/trezor-qrenc.git
[submodule "libopencm3"]
path = vendor/libopencm3
url = https://github.com/libopencm3/libopencm3.git
[submodule "vendor/nanopb"]
path = vendor/nanopb
url = https://github.com/nanopb/nanopb.git
60 changes: 60 additions & 0 deletions hardware-wallet/firmware/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
sudo: false
dist: trusty
language: c

addons:
apt:
packages:
- build-essential
- gcc-arm-none-eabi
- libnewlib-arm-none-eabi
- python3-pip

env:
global:
- MAKEFLAGS=-j2
- PYTHON=python3
- PROTOBUF_VERSION=3.4.0
matrix:
- DEBUG_LINK=0 FASTFLASH=0
- DEBUG_LINK=1 FASTFLASH=0
- DEBUG_LINK=0 FASTFLASH=1
- DEBUG_LINK=1 FASTFLASH=1

matrix:
include:
- addons:
apt:
packages:
- gcc-multilib
- python3-pip
env:
- EMULATOR=1 HEADLESS=1
- DEBUG_LINK=1
before_script:
- $PYTHON -m pip install --user pytest
- $PYTHON -m pip install --user ecdsa mnemonic
- $PYTHON -m pip install --user rlp
- $PYTHON -m pip install --user --no-deps git+https://github.com/trezor/python-trezor@master
script:
- script/cibuild
- script/test -k 'not skip_t1'

install:
- curl -LO "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip"
- unzip "protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" -d protoc
- export PATH="$(pwd)/protoc/bin:$PATH"
- $PYTHON -m pip install --user "protobuf==${PROTOBUF_VERSION}"

script:
- script/cibuild
- make -C bootloader
- make -C demo

notifications:
webhooks:
urls:
- http://ci-bot.satoshilabs.com:5000/travis
on_success: always
on_failure: always
on_start: always
165 changes: 165 additions & 0 deletions hardware-wallet/firmware/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
16 changes: 16 additions & 0 deletions hardware-wallet/firmware/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# initialize from the image

FROM debian:9

# install build tools and dependencies

RUN apt-get update && \
apt-get install -y \
build-essential curl unzip git python3 python3-pip gcc-arm-none-eabi libnewlib-arm-none-eabi

ENV PROTOBUF_VERSION=3.4.0
RUN curl -LO "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip"
RUN unzip "protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" -d /usr
RUN pip3 install "protobuf==${PROTOBUF_VERSION}" ecdsa

RUN ln -s python3 /usr/bin/python
18 changes: 18 additions & 0 deletions hardware-wallet/firmware/Dockerfile.emulator
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# initialize from the image

FROM debian:9

# install build tools and dependencies

RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y \
build-essential curl unzip git python3 python3-pip \
libsdl2-dev:i386 libsdl2-image-dev:i386 gcc-multilib

ENV PROTOBUF_VERSION=3.4.0
RUN curl -LO "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip"
RUN unzip "protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" -d /usr
RUN pip3 install "protobuf==${PROTOBUF_VERSION}" ecdsa

RUN ln -s python3 /usr/bin/python
33 changes: 33 additions & 0 deletions hardware-wallet/firmware/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ifneq ($(EMULATOR),1)
OBJS += startup.o
endif

OBJS += buttons.o
OBJS += layout.o
OBJS += oled.o
OBJS += rng.o
OBJS += serialno.o

ifneq ($(EMULATOR),1)
OBJS += setup.o
endif

OBJS += util.o
OBJS += memory.o

ifneq ($(EMULATOR),1)
OBJS += timer.o
endif

OBJS += gen/bitmaps.o
OBJS += gen/fonts.o

libtrezor.a: $(OBJS)
$(AR) rcs libtrezor.a $(OBJS)

include Makefile.include

.PHONY: vendor

vendor:
git submodule update --init
Loading