account

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: ISC Imports: 15 Imported by: 1

Documentation

Overview

SPDX-License-Identifier: ISC Copyright (c) 2014-2020 Bitmark Inc. Use of this source code is governed by an ISC license that can be found in the LICENSE file.

SPDX-License-Identifier: ISC Copyright (c) 2014-2020 Bitmark Inc. Use of this source code is governed by an ISC license that can be found in the LICENSE file.

SPDX-License-Identifier: ISC Copyright (c) 2014-2020 Bitmark Inc. Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	ChecksumLength            = 4
	Base58AccountNumberLength = 37
)
View Source
const (
	AlgEd25519 = 1
	AlgNaclBox = 2
)

Variables

View Source
var (
	ErrWrongNetwork          = errors.New("wrong network")
	ErrInvalidSeed           = errors.New("invalid seed")
	ErrInvalidRecoveryPhrase = errors.New("invalid recovery phrase")
	ErrInvalidChecksum       = errors.New("invalid checksum")
	ErrLangNotSupported      = errors.New("language not supported")
)

Functions

func ValidateAccountNumber

func ValidateAccountNumber(accountNumber string) (err error)

func Verify

func Verify(accountNumber string, message, signature []byte) error

Types

type Account

type Account interface {
	Version() Version
	Network() sdk.Network
	Seed() string
	RecoveryPhrase(language.Tag) ([]string, error)
	AccountNumber() string
	Bytes() []byte
	Sign(message []byte) (signature []byte)
}

func FromRecoveryPhrase

func FromRecoveryPhrase(words []string, lang language.Tag) (Account, error)

func FromSeed

func FromSeed(seedBase58Encoded string) (Account, error)

func New

func New() (Account, error)

type AccountV1

type AccountV1 struct {
	AuthKey AuthKey
	EncrKey EncrKey
	// contains filtered or unexported fields
}

func NewAccountV1

func NewAccountV1(seedCore *[seedCoreV1Length]byte) (*AccountV1, error)

func (*AccountV1) AccountNumber

func (acct *AccountV1) AccountNumber() string

func (*AccountV1) Bytes

func (acct *AccountV1) Bytes() []byte

func (*AccountV1) Network

func (acct *AccountV1) Network() sdk.Network

func (*AccountV1) RecoveryPhrase

func (acct *AccountV1) RecoveryPhrase(lang language.Tag) ([]string, error)

func (*AccountV1) Seed

func (acct *AccountV1) Seed() string

func (*AccountV1) Sign

func (acct *AccountV1) Sign(message []byte) []byte

func (AccountV1) Version

func (acct AccountV1) Version() Version

type AccountV2

type AccountV2 struct {
	AuthKey AuthKey
	EncrKey EncrKey
	// contains filtered or unexported fields
}

func NewAccountV2

func NewAccountV2(seedCore []byte) (*AccountV2, error)

func (*AccountV2) AccountNumber

func (acct *AccountV2) AccountNumber() string

func (*AccountV2) Bytes

func (acct *AccountV2) Bytes() []byte

func (*AccountV2) Network

func (acct *AccountV2) Network() sdk.Network

func (*AccountV2) RecoveryPhrase

func (acct *AccountV2) RecoveryPhrase(lang language.Tag) ([]string, error)

func (*AccountV2) Seed

func (acct *AccountV2) Seed() string

func (*AccountV2) Sign

func (acct *AccountV2) Sign(message []byte) []byte

func (AccountV2) Version

func (acct AccountV2) Version() Version

type AsymmetricKey

type AsymmetricKey interface {
	PrivateKeyBytes() []byte
	PublicKeyBytes() []byte
	Algorithm() int
}

type AuthKey

type AuthKey interface {
	AsymmetricKey

	Sign(message []byte) (signature []byte)
}

func NewAuthKey

func NewAuthKey(entropy []byte) (AuthKey, error)

type ED25519AuthKey

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

func (ED25519AuthKey) Algorithm

func (e ED25519AuthKey) Algorithm() int

func (ED25519AuthKey) PrivateKeyBytes

func (e ED25519AuthKey) PrivateKeyBytes() []byte

func (ED25519AuthKey) PublicKeyBytes

func (e ED25519AuthKey) PublicKeyBytes() []byte

func (ED25519AuthKey) Sign

func (e ED25519AuthKey) Sign(message []byte) []byte

type EncrKey

type EncrKey interface {
	AsymmetricKey
	Encrypt(plaintext []byte, peerPublicKey []byte) (ciphertext []byte, err error)
	Decrypt(ciphertext []byte, peerPublicKey []byte) (plaintext []byte, err error)
}

func NewEncrKey

func NewEncrKey(entropy []byte) (EncrKey, error)

type NaclBoxEncrKey

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

func (NaclBoxEncrKey) Algorithm

func (n NaclBoxEncrKey) Algorithm() int

func (NaclBoxEncrKey) Decrypt

func (n NaclBoxEncrKey) Decrypt(ciphertext []byte, peerPublicKey []byte) ([]byte, error)

func (NaclBoxEncrKey) Encrypt

func (n NaclBoxEncrKey) Encrypt(plaintext []byte, peerPublicKey []byte) ([]byte, error)

func (NaclBoxEncrKey) PrivateKeyBytes

func (n NaclBoxEncrKey) PrivateKeyBytes() []byte

func (NaclBoxEncrKey) PublicKeyBytes

func (n NaclBoxEncrKey) PublicKeyBytes() []byte

type Version

type Version string
const (
	V1 Version = "v1"
	V2 Version = "v2"
)

Directories

Path Synopsis
SPDX-License-Identifier: ISC Copyright (c) 2014-2020 Bitmark Inc.
SPDX-License-Identifier: ISC Copyright (c) 2014-2020 Bitmark Inc.

Jump to

Keyboard shortcuts

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