Documentation ¶
Index ¶
- Constants
- Variables
- func AccountDecoder(r io.Reader, n *int64, err *error) interface{}
- func AccountEncoder(o interface{}, w io.Writer, n *int64, err *error)
- func GenPrivKeyBytesFromSecret(secret string) []byte
- func HashSignBytes(chainID string, o Signable) []byte
- func SignBytes(chainID string, o Signable) []byte
- type Account
- type PrivAccount
- type PrivKey
- type PrivKeyEd25519
- type PubKey
- type PubKeyEd25519
- func (pubKey PubKeyEd25519) Address() []byte
- func (pubKey PubKeyEd25519) Equals(other PubKey) bool
- func (pubKey PubKeyEd25519) KeyString() string
- func (pubKey PubKeyEd25519) String() string
- func (pubKey PubKeyEd25519) ToCurve25519() *[32]byte
- func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool
- type Signable
- type Signature
- type SignatureEd25519
Constants ¶
const (
PrivKeyTypeEd25519 = byte(0x01)
)
Types of PrivKey implementations
const (
PubKeyTypeEd25519 = byte(0x01)
)
Types of PubKey implementations
const (
SignatureTypeEd25519 = byte(0x01)
)
Types of Signature implementations
Variables ¶
var AccountCodec = wire.Codec{ Encode: AccountEncoder, Decode: AccountDecoder, }
Functions ¶
func GenPrivKeyBytesFromSecret ¶
Generates 32 priv key bytes from secret
func HashSignBytes ¶
HashSignBytes is a convenience method for getting the hash of the bytes of a signable
Types ¶
type Account ¶
type Account struct { Address []byte `json:"address"` PubKey PubKey `json:"pub_key"` Sequence int `json:"sequence"` Balance int64 `json:"balance"` Code []byte `json:"code"` // VM code StorageRoot []byte `json:"storage_root"` // VM storage merkle root. Permissions ptypes.AccountPermissions `json:"permissions"` }
Account resides in the application state, and is mutated by transactions on the blockchain. Serialized by wire.[read|write]Reflect
type PrivAccount ¶
type PrivAccount struct { Address []byte `json:"address"` PubKey PubKey `json:"pub_key"` PrivKey PrivKey `json:"priv_key"` }
func GenPrivAccountFromPrivKeyBytes ¶
func GenPrivAccountFromPrivKeyBytes(privKeyBytes []byte) *PrivAccount
func GenPrivAccountFromSecret ¶
func GenPrivAccountFromSecret(secret string) *PrivAccount
Generates a new account with private key from SHA256 hash of a secret
func (*PrivAccount) Generate ¶
func (pA *PrivAccount) Generate(index int) *PrivAccount
func (*PrivAccount) String ¶
func (pA *PrivAccount) String() string
type PrivKeyEd25519 ¶
type PrivKeyEd25519 [64]byte
Implements PrivKey
func GenPrivKeyEd25519 ¶
func GenPrivKeyEd25519() PrivKeyEd25519
func (PrivKeyEd25519) Generate ¶
func (key PrivKeyEd25519) Generate(index int) PrivKeyEd25519
Deterministically generates new priv-key bytes from key.
func (PrivKeyEd25519) PubKey ¶
func (privKey PrivKeyEd25519) PubKey() PubKey
func (PrivKeyEd25519) Sign ¶
func (key PrivKeyEd25519) Sign(msg []byte) Signature
func (PrivKeyEd25519) String ¶
func (privKey PrivKeyEd25519) String() string
func (PrivKeyEd25519) ToCurve25519 ¶
func (privKey PrivKeyEd25519) ToCurve25519() *[32]byte
type PubKeyEd25519 ¶
type PubKeyEd25519 [32]byte
Implements PubKey
func (PubKeyEd25519) Address ¶
func (pubKey PubKeyEd25519) Address() []byte
TODO: Slicing the array gives us length prefixing but loses the type byte. Revisit if we add more pubkey types. For now, we artificially append the type byte in front to give us backwards compatibility for when the pubkey wasn't fixed length array
func (PubKeyEd25519) Equals ¶
func (pubKey PubKeyEd25519) Equals(other PubKey) bool
func (PubKeyEd25519) KeyString ¶
func (pubKey PubKeyEd25519) KeyString() string
Must return the full bytes in hex. Used for map keying, etc.
func (PubKeyEd25519) String ¶
func (pubKey PubKeyEd25519) String() string
func (PubKeyEd25519) ToCurve25519 ¶
func (pubKey PubKeyEd25519) ToCurve25519() *[32]byte
For use with golang/crypto/nacl/box If error, returns nil.
func (PubKeyEd25519) VerifyBytes ¶
func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool
TODO: Consider returning a reason for failure, or logging a runtime type mismatch.
type Signable ¶
Signable is an interface for all signable things. It typically removes signatures before serializing.
type SignatureEd25519 ¶
type SignatureEd25519 [64]byte
Implements Signature
func (SignatureEd25519) IsZero ¶
func (sig SignatureEd25519) IsZero() bool
func (SignatureEd25519) String ¶
func (sig SignatureEd25519) String() string