keyaddr

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

This is a library of Go code that is designed to be used in native apps for android and IOS.

To build it, you need gomobile, which you can install with:

go get golang.org/x/mobile/cmd/gomobile

To build IOS, you need XCode -- and its command line tools -- installed, and then you need to do:

gomobile init

After that, you can do:

gomobile bind -target ios -v

This will build IOS and generate Keyaddr.framework.

For Android, you need a current JDK, a current Android Studio, and a current NDK. Install the JDK and Android Studio, then set the location for ANDROID_HOME:

export ANDROID_HOME=$HOME/Library/Android/sdk/

If your android home is not there, then set this appropriately.

Download the ndk and put it wherever you like (I put it in my Downloads folder), then tell gomobile how to find it:

gomobile init -ndk ~/Downloads/android-ndk-r17b/

Then you can build the android target like this:

gomobile bind -target android -v

This will generate keyaddr-sources.jar and keyaddr.aar.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WordsFromBytes

func WordsFromBytes(lang string, data string) (string, error)

WordsFromBytes takes an array of bytes and converts it to a space-separated list of words that act as a mnemonic. A 16-byte input array will generate a list of 12 words.

func WordsFromPrefix

func WordsFromPrefix(lang string, prefix string, max int) string

WordsFromPrefix accepts a language and a prefix string and returns a sorted, space-separated list of words that match the given prefix. max can be used to limit the size of the returned list (if max is 0 then all matches are returned, which could be up to 2K if the prefix is empty).

func WordsToBytes

func WordsToBytes(lang string, w string) (string, error)

WordsToBytes takes a space-separated list of words and generates the set of bytes from which it was generated (or an error). The bytes are encoded as a base64 string using standard base64 encoding, as defined in RFC 4648.

Types

type Address

type Address struct {
	Address string
}

Address is an Ndau Address, derived from a public key.

type Key

type Key struct {
	Key string
}

Key is the object that contains a public or private key

func DeriveFrom

func DeriveFrom(parentKey string, parentPath, childPath string) (*Key, error)

DeriveFrom accepts a parent key and its known path, plus a desired child path and derives the child key from the parent according to the path info. Note that the parent's known path is simply believed -- we have no mechanism to check that it's true.

func FromOldString

func FromOldString(s string) (*Key, error)

FromOldString is FromString, but it operates on the old key serialization format.

The returned object will be serialized in the new format, so future calls to FromString will succeed.

func FromString

func FromString(s string) (*Key, error)

FromString acts like a constructor so that the wallet can build a Key object from a string representation of it.

func KeyFromExtended

func KeyFromExtended(k *key.ExtendedKey) (*Key, error)

KeyFromExtended constructs a `*Key` from a `*key.ExtendedKey`

func KeyFromPrivate

func KeyFromPrivate(k signature.PrivateKey) (*Key, error)

KeyFromPrivate constructs a `*Key` from a `signature.PrivateKey`

func KeyFromPublic

func KeyFromPublic(k signature.PublicKey) (*Key, error)

KeyFromPublic constructs a `*Key` from a `signature.PublicKey`

func NewKey

func NewKey(seedstr string) (*Key, error)

NewKey takes a seed (an array of bytes encoded as a base64 string) and creates a private master key from it. The key is returned as a string representation of the key; it is converted to and from the internal representation by its member functions.

func (*Key) Child

func (k *Key) Child(n int32) (*Key, error)

Child returns the n'th child of the given extended key. The child is of the same type (public or private) as the parent. Although n is typed as a signed integer, this is due to the limitations of gomobile; n may not be negative. It is an error if the given key is a hardened key.

func (*Key) HardenedChild

func (k *Key) HardenedChild(n int32) (*Key, error)

HardenedChild returns the n'th hardened child of the given extended key. The parent key must be a private key. A HardenedChild is guaranteed to have been derived from a private key. Although n is typed as a signed integer, this is due to the limitations of gomobile; n may not be negative. It is an error if the given key is already a hardened key.

func (*Key) IsPrivate

func (k *Key) IsPrivate() (bool, error)

IsPrivate tests if a given key is a private key; will return non-nil error if the key is invalid.

func (*Key) NdauAddress

func (k *Key) NdauAddress() (*Address, error)

NdauAddress returns the ndau address associated with the given key. Key can be either public or private; if it is private it will be converted to a public key first.

func (*Key) Sign

func (k *Key) Sign(msgstr string) (*Signature, error)

Sign uses the given key to sign a message; the message must be the standard base64 encoding of the bytes of the message. It returns a signature object. The key must be a private key.

func (Key) ToExtended

func (k Key) ToExtended() (*key.ExtendedKey, error)

ToExtended constructs a `*key.ExtendedKey` from a `Key`

func (*Key) ToPrivateKey

func (k *Key) ToPrivateKey() (signature.PrivateKey, error)

ToPrivateKey constructs a `signature.PrivateKey` from a `*Key`

func (*Key) ToPublic

func (k *Key) ToPublic() (*Key, error)

ToPublic returns an extended public key from any other extended key. If the key is an extended private key, it generates the matching public key. If the key is already a public key, it just returns itself. It is an error if the key is hardened.

func (*Key) ToPublicKey

func (k *Key) ToPublicKey() (signature.PublicKey, error)

ToPublicKey constructs a `signature.PublicKey` from a `*Key`

type Signature

type Signature struct {
	Signature string
}

Signature is the result of signing a block of data with a key.

func SignatureFrom

func SignatureFrom(sig signature.Signature) (*Signature, error)

SignatureFrom converts a `signature.Signature` into a `*Signature`

func (Signature) ToSignature

func (s Signature) ToSignature() (signature.Signature, error)

ToSignature converts a `Signature` into a `signature.Signature`

Jump to

Keyboard shortcuts

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