crypto

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const AddressSize = 26

Variables

View Source
var GlobalAddress, _ = AddressFromString("gbnDyGpPVijzB74qUhiEAvgdZYMdK2Uvdkh")

Functions

func GenerateKey

func GenerateKey(random io.Reader) (PublicKey, PrivateKey)

func GenerateKeyFromSecret

func GenerateKeyFromSecret(secret string) (PublicKey, PrivateKey)

func Sha3

func Sha3(data ...[]byte) []byte

Types

type Address

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

func AccountAddress

func AccountAddress(bs []byte) (Address, error)

func AddressFromRawBytes

func AddressFromRawBytes(bs []byte) (Address, error)

func AddressFromString

func AddressFromString(text string) (Address, error)

func ContractAddress

func ContractAddress(bs []byte) (Address, error)

func DeriveContractAddress

func DeriveContractAddress(addr Address, sequence uint64) Address

func ValidatorAddress

func ValidatorAddress(bs []byte) (Address, error)

func (*Address) EnsureValid

func (addr *Address) EnsureValid() error

func (Address) EqualsTo

func (addr Address) EqualsTo(right Address) bool

func (*Address) IsAccountAddress

func (addr *Address) IsAccountAddress() bool

func (*Address) IsContractAddress

func (addr *Address) IsContractAddress() bool

func (*Address) IsValidatorAddress

func (addr *Address) IsValidatorAddress() bool

func (*Address) Marshal added in v0.3.0

func (addr *Address) Marshal() ([]byte, error)

Gogo proto support

func (Address) MarshalAmino

func (addr Address) MarshalAmino() ([]byte, error)

func (Address) MarshalText

func (addr Address) MarshalText() ([]byte, error)

func (*Address) MarshalTo added in v0.3.0

func (addr *Address) MarshalTo(data []byte) (int, error)

func (Address) RawBytes

func (addr Address) RawBytes() []byte

func (*Address) Size added in v0.3.0

func (addr *Address) Size() int

func (Address) String

func (addr Address) String() string

func (*Address) Unmarshal added in v0.3.0

func (addr *Address) Unmarshal(bs []byte) error

func (*Address) UnmarshalAmino

func (addr *Address) UnmarshalAmino(bs []byte) error

func (*Address) UnmarshalText

func (addr *Address) UnmarshalText(text []byte) error

func (Address) Verify

func (addr Address) Verify(pb PublicKey) bool

type PrivateKey

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

func PrivateKeyFromRawBytes

func PrivateKeyFromRawBytes(bs []byte) (PrivateKey, error)

PrivateKeyFromRawBytes constructs a private key from ed25519 raw bytes.

func PrivateKeyFromString

func PrivateKeyFromString(text string) (PrivateKey, error)

PrivateKeyFromString constructs a private key from base58 encoding text and check the prefix and checksum

func (*PrivateKey) EnsureValid

func (pv *PrivateKey) EnsureValid() error

func (PrivateKey) MarshalAmino

func (pv PrivateKey) MarshalAmino() ([]byte, error)

func (PrivateKey) MarshalText

func (pv PrivateKey) MarshalText() ([]byte, error)

func (PrivateKey) PublicKey

func (pv PrivateKey) PublicKey() PublicKey

func (PrivateKey) RawBytes

func (pv PrivateKey) RawBytes() []byte

/ ------- / CASTING RawBytes returns the ed25519 raw bytes of the private key

func (PrivateKey) Sign

func (pv PrivateKey) Sign(msg []byte) (Signature, error)

func (PrivateKey) SignWithoutHash added in v0.3.0

func (pv PrivateKey) SignWithoutHash(msg []byte) (Signature, error)

func (PrivateKey) String

func (pv PrivateKey) String() string

String return the base58 encoding text of the private key with the prefix and checksum

func (*PrivateKey) UnmarshalAmino

func (pv *PrivateKey) UnmarshalAmino(bs []byte) error

func (*PrivateKey) UnmarshalText

func (pv *PrivateKey) UnmarshalText(text []byte) error

type PublicKey

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

PublicKey

func PublicKeyFromRawBytes

func PublicKeyFromRawBytes(bs []byte) (PublicKey, error)

PublicKeyFromRawBytes reads the raw bytes and returns an ed25519 public key.

func PublicKeyFromString

func PublicKeyFromString(text string) (PublicKey, error)

PrivateKeyFromString constructs a private key from base58 encoding text and check the prefix and checksum

func (PublicKey) ABCIPubKey

func (pb PublicKey) ABCIPubKey() tmABCI.PubKey

func (PublicKey) AccountAddress

func (pb PublicKey) AccountAddress() Address

func (*PublicKey) Encode added in v0.3.0

func (pb *PublicKey) Encode() ([]byte, error)

func (*PublicKey) EnsureValid

func (pb *PublicKey) EnsureValid() error

func (*PublicKey) Marshal added in v0.3.0

func (pb *PublicKey) Marshal() ([]byte, error)

protobuf function

func (PublicKey) MarshalAmino

func (pb PublicKey) MarshalAmino() ([]byte, error)

func (PublicKey) MarshalText

func (pb PublicKey) MarshalText() ([]byte, error)

func (*PublicKey) MarshalTo added in v0.3.0

func (pb *PublicKey) MarshalTo(data []byte) (int, error)

func (PublicKey) RawBytes

func (pb PublicKey) RawBytes() []byte

RawBytes returns the ed25519 raw bytes of the public key

func (*PublicKey) Size added in v0.3.0

func (pb *PublicKey) Size() int

func (PublicKey) String

func (pb PublicKey) String() string

String return the base58 encoding text of the public key with the prefix and checksum

func (PublicKey) TMPubKey

func (pb PublicKey) TMPubKey() tmCrypto.PubKey

TMPubKey returns the tendermint PubKey.

func (*PublicKey) Unmarshal added in v0.3.0

func (pb *PublicKey) Unmarshal(bs []byte) error

func (*PublicKey) UnmarshalAmino

func (pb *PublicKey) UnmarshalAmino(bs []byte) error

func (*PublicKey) UnmarshalText

func (pb *PublicKey) UnmarshalText(text []byte) error

func (PublicKey) ValidatorAddress

func (pb PublicKey) ValidatorAddress() Address

func (PublicKey) Verify

func (pb PublicKey) Verify(msg []byte, signature Signature) bool

type Signatory

type Signatory struct {
	PublicKey PublicKey `json:"publicKey"`
	Signature Signature `json:"signature"`
}

Signatory contains signature and PublicKey to identify the signer

type Signature

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

func SignatureFromRawBytes

func SignatureFromRawBytes(bs []byte) (Signature, error)

func SignatureFromString

func SignatureFromString(text string) (Signature, error)

func (*Signature) EnsureValid

func (sig *Signature) EnsureValid() error

func (Signature) MarshalAmino

func (sig Signature) MarshalAmino() ([]byte, error)

func (Signature) MarshalText

func (sig Signature) MarshalText() ([]byte, error)

func (Signature) RawBytes

func (sig Signature) RawBytes() []byte

func (Signature) String

func (sig Signature) String() string

func (*Signature) UnmarshalAmino

func (sig *Signature) UnmarshalAmino(bs []byte) error

func (*Signature) UnmarshalText

func (sig *Signature) UnmarshalText(text []byte) error

type Signer

type Signer interface {
	Address() Address
	PublicKey() PublicKey
	Sign(msg []byte) (Signature, error)
	SignWithoutHash(msg []byte) (Signature, error) // Sign the message without hashing it
}

func NewAccountSigner

func NewAccountSigner(pv PrivateKey) Signer

func NewValidatorSigner

func NewValidatorSigner(pv PrivateKey) Signer

Jump to

Keyboard shortcuts

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