Documentation ¶
Index ¶
- Constants
- func Compare(l WalletAddress, r WalletAddress) int
- func CompareHashes(l [HASH_SIZE]byte, r [HASH_SIZE]byte) int
- func CompareWalletAddress(l WalletAddress, r WalletAddress) bool
- func GenerateKey() (ed25519.PublicKey, ed25519.PrivateKey, error)
- func HashBytes(buf []byte) [HASH_SIZE]byte
- func IsWalletType(WalletType uint16) bool
- func LoadKeyFromFile(filename string) ([]byte, error)
- func LoadKeyFromHex(key string) ([]byte, error)
- func PubKeyToBytes(pub crypto.PublicKey) ([]byte, error)
- type BasicWallet
- func (w BasicWallet) Filename() string
- func (w BasicWallet) Length() uint16
- func (wal BasicWallet) MarshalBinary() ([]byte, error)
- func (w BasicWallet) Private() ed25519.PrivateKey
- func (w BasicWallet) PrivateBytes() [PRIVATE_KEY_SIZE]byte
- func (w BasicWallet) Public() ed25519.PublicKey
- func (w BasicWallet) Save() error
- func (w BasicWallet) SaveKeys(filename string) error
- func (w BasicWallet) Sign(message []byte) ([]byte, error)
- func (w BasicWallet) Type() uint16
- func (w BasicWallet) Verify(message []byte) bool
- func (w BasicWallet) WalletAddress() WalletAddress
- type BasicWalletAddress
- type Signature
- type TestWallet
- func (w TestWallet) CreatorName() string
- func (w TestWallet) Filename() string
- func (w TestWallet) Length() uint16
- func (w TestWallet) MarshalBinary() ([]byte, error)
- func (w TestWallet) Private() ed25519.PrivateKey
- func (w TestWallet) PrivateBytes() [PRIVATE_KEY_SIZE]byte
- func (w TestWallet) Public() ed25519.PublicKey
- func (w TestWallet) Save() error
- func (w TestWallet) SaveKeys(filename string) error
- func (w TestWallet) Sign(message []byte) ([]byte, error)
- func (w TestWallet) Type() uint16
- func (w TestWallet) Verify(message []byte) bool
- func (w TestWallet) WalletAddress() WalletAddress
- type TestWalletAddress
- type Wallet
- type WalletAddress
- type WalletKey
Constants ¶
const ( BASIC_WALLET uint16 = 0 TEST_WALLET uint16 = 1 )
List of wallet types
const ( PUBLIC_KEY_SIZE = ed25519.PublicKeySize PRIVATE_KEY_SIZE = ed25519.PrivateKeySize SIGNATURE_SIZE = ed25519.SignatureSize HASH_SIZE = sha256.Size )
AddressSize represents the new WalletAddress size. PUBLIC_KEY_SIZE is now only used to represent the size of the public key, not the WalletAddress.
const ( CREATOR_NAME_SIZE = 10 TEST_WALLET_ADDR_SIZE = PUBLIC_KEY_SIZE + CREATOR_NAME_SIZE + 4 )
const (
BASIC_WALLET_ADDR_SIZE = PUBLIC_KEY_SIZE + 4
)
const UINT64_BYTES = 8
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
func Compare(l WalletAddress, r WalletAddress) int
func CompareWalletAddress ¶
func CompareWalletAddress(l WalletAddress, r WalletAddress) bool
func GenerateKey ¶
func GenerateKey() (ed25519.PublicKey, ed25519.PrivateKey, error)
func LoadKeyFromFile ¶
func LoadKeyFromHex ¶
Types ¶
type BasicWallet ¶
type BasicWallet struct { Type_ uint16 Length_ uint16 Filename_ string Public_ ed25519.PublicKey Private_ ed25519.PrivateKey }
func NewSilvermintWallet ¶
func NewSilvermintWallet(addr []byte) BasicWallet
func NewSilvermintWalletFromPrivKey ¶
func NewSilvermintWalletFromPrivKey(privKey []byte) BasicWallet
func (BasicWallet) Filename ¶
func (w BasicWallet) Filename() string
func (BasicWallet) Length ¶
func (w BasicWallet) Length() uint16
func (BasicWallet) MarshalBinary ¶
func (wal BasicWallet) MarshalBinary() ([]byte, error)
func (BasicWallet) Private ¶
func (w BasicWallet) Private() ed25519.PrivateKey
func (BasicWallet) PrivateBytes ¶
func (w BasicWallet) PrivateBytes() [PRIVATE_KEY_SIZE]byte
func (BasicWallet) Public ¶
func (w BasicWallet) Public() ed25519.PublicKey
func (BasicWallet) Save ¶
func (w BasicWallet) Save() error
func (BasicWallet) SaveKeys ¶
func (w BasicWallet) SaveKeys(filename string) error
func (BasicWallet) Type ¶
func (w BasicWallet) Type() uint16
func (BasicWallet) Verify ¶
func (w BasicWallet) Verify(message []byte) bool
func (BasicWallet) WalletAddress ¶
func (w BasicWallet) WalletAddress() WalletAddress
WalletAddress returns Address which is the marshal binary of the wallet struct, this is the Public Address that is now used to represent a Wallet, not just the PublicKey
type BasicWalletAddress ¶
type BasicWalletAddress struct {
Address_ [BASIC_WALLET_ADDR_SIZE]byte
}
func (BasicWalletAddress) Address ¶
func (sa BasicWalletAddress) Address() []byte
func (BasicWalletAddress) Length ¶
func (sa BasicWalletAddress) Length() uint16
func (BasicWalletAddress) Uint64 ¶
func (sa BasicWalletAddress) Uint64() uint64
type Signature ¶
type Signature [SIGNATURE_SIZE]byte
type TestWallet ¶
type TestWallet struct { Type_ uint16 Length_ uint16 Filename_ string CreatorName_ string Public_ ed25519.PublicKey Private_ ed25519.PrivateKey }
func NewTestWallet ¶
func NewTestWallet(addr []byte) TestWallet
func (TestWallet) CreatorName ¶
func (w TestWallet) CreatorName() string
func (TestWallet) Filename ¶
func (w TestWallet) Filename() string
func (TestWallet) Length ¶
func (w TestWallet) Length() uint16
func (TestWallet) MarshalBinary ¶
func (w TestWallet) MarshalBinary() ([]byte, error)
func (TestWallet) Private ¶
func (w TestWallet) Private() ed25519.PrivateKey
func (TestWallet) PrivateBytes ¶
func (w TestWallet) PrivateBytes() [PRIVATE_KEY_SIZE]byte
func (TestWallet) Public ¶
func (w TestWallet) Public() ed25519.PublicKey
func (TestWallet) Save ¶
func (w TestWallet) Save() error
func (TestWallet) SaveKeys ¶
func (w TestWallet) SaveKeys(filename string) error
func (TestWallet) Type ¶
func (w TestWallet) Type() uint16
func (TestWallet) Verify ¶
func (w TestWallet) Verify(message []byte) bool
func (TestWallet) WalletAddress ¶
func (w TestWallet) WalletAddress() WalletAddress
WalletAddress returns Address which is the marshal binary of the wallet struct, this is the Public Address that is now used to represent a Wallet, not just the PublicKey
type TestWalletAddress ¶
type TestWalletAddress struct {
Address_ [TEST_WALLET_ADDR_SIZE]byte
}
func (TestWalletAddress) Address ¶
func (a TestWalletAddress) Address() []byte
func (TestWalletAddress) Length ¶
func (a TestWalletAddress) Length() uint16
func (TestWalletAddress) Uint64 ¶
func (a TestWalletAddress) Uint64() uint64
type Wallet ¶
type Wallet interface { Type() uint16 Length() uint16 Filename() string Public() ed25519.PublicKey Private() ed25519.PrivateKey WalletAddress() WalletAddress PrivateBytes() [PRIVATE_KEY_SIZE]byte Save() error SaveKeys(filename string) error Sign(message []byte) ([]byte, error) Verify(message []byte) bool MarshalBinary() ([]byte, error) }
func LoadWalletFromFile ¶
func UnmarshalBinary ¶
NB(chuck): Kinda dumb, but we can't have an UnmarshalBinary([]byte) error interface function for a Wallet. That would require changing the Wallet interface from being an interface to {BasicWallet, TestWallet} to being an interface to {*BasicWallet, *TestWallet} (since UnmarshalBinary must have a pointer receiver). This changes all the Ledger stuff because we could no longer readily store/lookup wallets in maps or check them for equality, due to the fact that we'd be comparing pointers instead of structs.
type WalletAddress ¶
func NewWalletAddress ¶
func NewWalletAddress(address []byte) WalletAddress
type WalletKey ¶
type WalletKey [PRIVATE_KEY_SIZE]byte
WalletAddress is now a marshal binary containing: Type, Length, and PublicKey.