cerrojo

package module
v0.0.0-...-a01bbec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2017 License: Apache-2.0 Imports: 28 Imported by: 0

README

CERROJO

Go package to work with TREZOR and KEEPKEY devices. This repository is an unofficial package written in Go (golang), for any official package, code or tool, please go to the official TREZOR repository or KEEPKEY repository.

What is TREZOR?

TREZOR is a single purpose device which allows you to make secure Bitcoin transactions. With TREZOR, transactions are completely safe even when initiated on a compromised or vulnerable computer.

What is KEEPKEY?

KeepKey is a hardware wallet that secures bitcoin, ethereum, litecoin, dogecoin, dash, and namecoin. Your assets are protected from hackers and thieves..

Installation

$ go get github.com/conejoninja/cerrojo

Documentation

None yet, it's a work in progress

Supported methods

Almost everything is supported except debuglink related stuff. Transactions methods are done but not tested.

Tests

Go to the tests folder and run them with

// Put your device in bootloader mode
go test -v cerrojo_bootloader_test.go
// Disconnect and connect your device in normal mode
go test -v cerrojo_test.go

Running tests the traditional Go way (go test) will not work, as for cerrojo_bootloader_test.go to run you need to put your device in bootloader mode, the rest of the tests are run in normal mode.

Contributing to this project:

If you find any improvement or issue you want to fix, feel free to send me a pull request.

License

This is distributed under the Apache License v2.0

Copyright 2016-2017 Daniel Esteban - conejo@conejo.me

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.

Notes

For a TREZOR-specific version of this project, please refer to TESORO project, which was the seed of this one.

If you would like to donate via Bitcoin, please send your donation to this wallet:

Bitcoin: 1G9d7uVvioNt8Emsv6fVmCdAPc41nX1c8J

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AES256GCMDecrypt

func AES256GCMDecrypt(cipheredText, key, nonce, tag []byte) ([]byte, error)

func AES256GCMMEncrypt

func AES256GCMMEncrypt(plainText, key []byte) ([]byte, []byte)

func BIP32Path

func BIP32Path(keys []uint32) string

func DecryptEntry

func DecryptEntry(content, key string) (string, error)

func EncryptEntry

func EncryptEntry(content, key string) []byte

func EncryptStorage

func EncryptStorage(s Storage, key string) []byte

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

func GetFileEncKey

func GetFileEncKey(masterKey string) (string, string, string)

func PNGToString

func PNGToString(filename string) ([]byte, error)

func StringToBIP32Path

func StringToBIP32Path(str string) []uint32

func URIToIdentity

func URIToIdentity(uri string) types.IdentityTyper

func ValidBIP32

func ValidBIP32(path string) bool

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) ButtonAck

func (c *Client) ButtonAck() []byte

func (*Client) Call

func (c *Client) Call(msg []byte) (string, uint16)

func (*Client) ChangePin

func (c *Client) ChangePin() []byte

func (*Client) CipherKeyValue

func (c *Client) CipherKeyValue(encrypt bool, key string, value []byte, address []uint32, iv []byte, askOnEncrypt, askOnDecrypt bool) []byte

func (*Client) ClearSession

func (c *Client) ClearSession() []byte

func (*Client) CloseTransport

func (c *Client) CloseTransport()

func (*Client) DecryptMessage

func (c *Client) DecryptMessage(path string, nonce, message, hmac []byte) []byte

func (*Client) EncryptMessage

func (c *Client) EncryptMessage(pubkey, message string, displayOnly bool, path, coinName string) []byte

func (*Client) EntropyAck

func (c *Client) EntropyAck(entropy []byte) []byte

func (*Client) EstimateTxSize

func (c *Client) EstimateTxSize(outputsCount, inputsCount uint32, coinName string) []byte

func (*Client) EthereumGetAddress

func (c *Client) EthereumGetAddress(addressN []uint32, showDisplay bool) []byte

func (*Client) FirmwareErase

func (c *Client) FirmwareErase() []byte

func (*Client) FirmwareUpload

func (c *Client) FirmwareUpload(payload []byte) []byte

func (*Client) GetAddress

func (c *Client) GetAddress(addressN []uint32, showDisplay bool, coinName string) []byte

func (*Client) GetECDHSessionKey

func (c *Client) GetECDHSessionKey(uri string, index uint32, peerPublicKey []byte, ecdsaCurveName string) []byte

func (*Client) GetEntropy

func (c *Client) GetEntropy(size uint32) []byte

func (*Client) GetEntryNonce

func (c *Client) GetEntryNonce(title, username, nonce string) []byte

func (*Client) GetFeatures

func (c *Client) GetFeatures() []byte

func (*Client) GetMasterKey

func (c *Client) GetMasterKey() []byte

func (*Client) GetPublicKey

func (c *Client) GetPublicKey(address []uint32) []byte

func (*Client) Header

func (c *Client) Header(msgType common.MessageType, msg []byte) []byte

func (*Client) Initialize

func (c *Client) Initialize() []byte

func (*Client) LoadDevice

func (c *Client) LoadDevice(mnemonic string, passphraseProtection bool, label, pin string, SkipChecksum bool, U2FCounter uint32) []byte

func (*Client) PassphraseAck

func (c *Client) PassphraseAck(str string) []byte

func (*Client) PinMatrixAck

func (c *Client) PinMatrixAck(str string) []byte

func (*Client) Ping

func (c *Client) Ping(str string, pinProtection, passphraseProtection, buttonProtection bool) []byte

func (*Client) Read

func (c *Client) Read() (string, uint16)

func (*Client) ReadUntil

func (c *Client) ReadUntil() (string, uint16)

func (*Client) RecoveryDevice

func (c *Client) RecoveryDevice(wordCount uint32, passphraseProtection, pinProtection bool, label string, EnforceWordList bool, U2FCounter uint32) []byte

func (*Client) ResetDevice

func (c *Client) ResetDevice(displayRandom bool, strength uint32, passphraseProtection, pinProtection bool, label string, U2FCounter uint32) []byte

func (*Client) SetEntryNonce

func (c *Client) SetEntryNonce(title, username, nonce string) []byte

func (*Client) SetHomescreen

func (c *Client) SetHomescreen(homescreen []byte) []byte

func (*Client) SetLabel

func (c *Client) SetLabel(label string) []byte

func (*Client) SetTransport

func (c *Client) SetTransport(t transport.Transport, d devices.Device)

func (*Client) SetU2FCounter

func (c *Client) SetU2FCounter(U2FCounter uint32) []byte

func (*Client) SignIdentity

func (c *Client) SignIdentity(uri string, challengeHidden []byte, challengeVisual string, index uint32) []byte

func (*Client) SignMessage

func (c *Client) SignMessage(message []byte) []byte

func (*Client) SignTx

func (c *Client) SignTx(outputsCount, inputsCount uint32, coinName string, version, lockTime uint32) []byte

func (*Client) TxAck

func (c *Client) TxAck(tx types.TransactionTyper) []byte

func (*Client) VerifyMessage

func (c *Client) VerifyMessage(address, signature string, message []byte) []byte

func (*Client) WipeDevice

func (c *Client) WipeDevice() []byte

func (*Client) WordAck

func (c *Client) WordAck(str string) []byte

type Config

type Config struct {
	OrderType string `json:"orderType"`
}

type EncryptedData

type EncryptedData struct {
	Type string `json:"type"`
	Data []byte `json:"data"`
}

func (EncryptedData) MarshalJSON

func (e EncryptedData) MarshalJSON() ([]byte, error)

TPM uses []int instead of []byte

type Entry

type Entry struct {
	Title    string        `json:"title"`
	Username string        `json:"username"`
	Nonce    string        `json:"nonce"`
	Note     string        `json:"note"`
	Password EncryptedData `json:"password"`
	SafeNote EncryptedData `json:"safe_note"`
	Tags     []int         `json:"tags"`
}

func (*Entry) Equal

func (e *Entry) Equal(entry Entry) bool

TODO : Work on this

type Storage

type Storage struct {
	Version string           `json:"version"`
	Config  Config           `json:"config"`
	Tags    map[string]Tag   `json:"tags"`
	Entries map[string]Entry `json:"entries"`
}

func DecryptStorage

func DecryptStorage(content, key string) (Storage, error)

type Tag

type Tag struct {
	Title  string `json:"title"`
	Icon   string `json:"icon"`
	Active string `json:"active"`
}

type TxRequest

type TxRequest struct {
	Details *types.TxRequestDetailsTyper `json:"details,omitempty"`
	Type    types.RequestType            `json:"type,omitempty"`
}

Directories

Path Synopsis
pb
exchange
Package exchange is a generated protocol buffer package.
Package exchange is a generated protocol buffer package.
google/protobuf
Package google_protobuf is a generated protocol buffer package.
Package google_protobuf is a generated protocol buffer package.
keepkey/exchange
Package exchange is a generated protocol buffer package.
Package exchange is a generated protocol buffer package.
keepkey/messages
Package messages is a generated protocol buffer package.
Package messages is a generated protocol buffer package.
keepkey/storage
Package storage is a generated protocol buffer package.
Package storage is a generated protocol buffer package.
keepkey/types
Package types is a generated protocol buffer package.
Package types is a generated protocol buffer package.
trezor/config
Package config is a generated protocol buffer package.
Package config is a generated protocol buffer package.
trezor/messages
Package messages is a generated protocol buffer package.
Package messages is a generated protocol buffer package.
trezor/storage
Package storage is a generated protocol buffer package.
Package storage is a generated protocol buffer package.
trezor/types
Package types is a generated protocol buffer package.
Package types is a generated protocol buffer package.
tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL