Documentation
¶
Index ¶
- func WordsFromBytes(lang string, data string) (string, error)
- func WordsFromPrefix(lang string, prefix string, max int) string
- func WordsToBytes(lang string, w string) (string, error)
- type Address
- type Key
- func DeriveFrom(parentKey string, parentPath, childPath string) (*Key, error)
- func FromOldString(s string) (*Key, error)
- func FromString(s string) (*Key, error)
- func KeyFromExtended(k *key.ExtendedKey) (*Key, error)
- func KeyFromPrivate(k signature.PrivateKey) (*Key, error)
- func KeyFromPublic(k signature.PublicKey) (*Key, error)
- func NewKey(seedstr string) (*Key, error)
- func (k *Key) Child(n int32) (*Key, error)
- func (k *Key) HardenedChild(n int32) (*Key, error)
- func (k *Key) IsPrivate() (bool, error)
- func (k *Key) NdauAddress() (*Address, error)
- func (k *Key) Sign(msgstr string) (*Signature, error)
- func (k Key) ToExtended() (*key.ExtendedKey, error)
- func (k *Key) ToPrivateKey() (signature.PrivateKey, error)
- func (k *Key) ToPublic() (*Key, error)
- func (k *Key) ToPublicKey() (signature.PublicKey, error)
- type Signature
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WordsFromBytes ¶
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 ¶
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).
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 ¶
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 ¶
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 ¶
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 ¶
KeyFromPublic constructs a `*Key` from a `signature.PublicKey`
func NewKey ¶
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 ¶
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 ¶
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 ¶
IsPrivate tests if a given key is a private key; will return non-nil error if the key is invalid.
func (*Key) NdauAddress ¶
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 ¶
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`
type Signature ¶
type Signature struct {
Signature string
}
Signature is the result of signing a block of data with a key.
func SignatureFrom ¶
SignatureFrom converts a `signature.Signature` into a `*Signature`