crypto

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const HashSize = 32
View Source
const PrivateKeySize = 32
View Source
const PublicKeySize = 96
View Source
const SignatureSize = 48

Variables

View Source
var TreasuryAddress = Address{
	// contains filtered or unexported fields
}
View Source
var UndefHash = Hash{/* contains filtered or unexported fields */}

Functions

func GenerateTestKeyPair added in v1.0.0

func GenerateTestKeyPair() (Address, PublicKey, PrivateKey)

--------- For tests

func Hash160 added in v1.0.0

func Hash160(data []byte) []byte

func Hash256 added in v1.0.0

func Hash256(data []byte) []byte

func RandomKeyPair added in v1.0.0

func RandomKeyPair() (Address, PublicKey, PrivateKey)

func VerifyAggregated added in v1.0.0

func VerifyAggregated(aggregated Signature, pubs []PublicKey, msg []byte) bool

Types

type Address

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

func AddressFromRawBytes

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

func AddressFromString

func AddressFromString(text string) (Address, error)

func (Address) EqualsTo

func (addr Address) EqualsTo(right Address) bool

func (Address) Fingerprint

func (addr Address) Fingerprint() string

func (Address) MarshalCBOR

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

func (Address) MarshalJSON

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

func (Address) MarshalText

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

func (Address) RawBytes

func (addr Address) RawBytes() []byte

func (*Address) SanityCheck

func (addr *Address) SanityCheck() error

func (Address) String

func (addr Address) String() string

func (*Address) UnmarshalCBOR

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

func (*Address) UnmarshalJSON

func (addr *Address) UnmarshalJSON(bz []byte) error

func (*Address) UnmarshalText

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

func (Address) Verify

func (addr Address) Verify(pb PublicKey) bool

type Hash added in v1.0.0

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

func GenerateTestHash added in v1.0.0

func GenerateTestHash() Hash

--------- For tests

func HashFromRawBytes added in v1.0.0

func HashFromRawBytes(data []byte) (Hash, error)

func HashFromString added in v1.0.0

func HashFromString(str string) (Hash, error)

func HashH added in v1.0.0

func HashH(data []byte) Hash

func (Hash) EqualsTo added in v1.0.0

func (h Hash) EqualsTo(r Hash) bool

func (Hash) Fingerprint added in v1.0.0

func (h Hash) Fingerprint() string

func (Hash) IsUndef added in v1.0.0

func (h Hash) IsUndef() bool

func (Hash) MarshalCBOR added in v1.0.0

func (h Hash) MarshalCBOR() ([]byte, error)

func (Hash) MarshalJSON added in v1.0.0

func (h Hash) MarshalJSON() ([]byte, error)

func (Hash) MarshalText added in v1.0.0

func (h Hash) MarshalText() ([]byte, error)

func (Hash) RawBytes added in v1.0.0

func (h Hash) RawBytes() []byte

func (Hash) SanityCheck added in v1.0.0

func (h Hash) SanityCheck() error

func (Hash) String added in v1.0.0

func (h Hash) String() string

func (*Hash) UnmarshalCBOR added in v1.0.0

func (h *Hash) UnmarshalCBOR(bs []byte) error

func (*Hash) UnmarshalJSON added in v1.0.0

func (h *Hash) UnmarshalJSON(bz []byte) error

func (*Hash) UnmarshalText added in v1.0.0

func (h *Hash) UnmarshalText(text []byte) error

type PrivateKey

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

func PrivateKeyFromRawBytes added in v1.0.0

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

func PrivateKeyFromSeed added in v1.0.0

func PrivateKeyFromSeed(seed []byte) (PrivateKey, error)

func PrivateKeyFromString added in v1.0.0

func PrivateKeyFromString(text string) (PrivateKey, error)

func (*PrivateKey) EqualsTo

func (pv *PrivateKey) EqualsTo(right PrivateKey) bool

func (PrivateKey) MarshalCBOR

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

func (PrivateKey) MarshalJSON

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

func (PrivateKey) MarshalText added in v1.0.0

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

func (*PrivateKey) PublicKey

func (pv *PrivateKey) PublicKey() PublicKey

func (PrivateKey) RawBytes

func (pv PrivateKey) RawBytes() []byte

func (*PrivateKey) SanityCheck

func (pv *PrivateKey) SanityCheck() error

func (*PrivateKey) Sign

func (pv *PrivateKey) Sign(msg []byte) Signature

func (PrivateKey) String

func (pv PrivateKey) String() string

func (*PrivateKey) UnmarshalCBOR added in v1.0.0

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

func (*PrivateKey) UnmarshalJSON added in v1.0.0

func (pv *PrivateKey) UnmarshalJSON(bz []byte) error

func (*PrivateKey) UnmarshalText added in v1.0.0

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

type PublicKey

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

func PublicKeyFromRawBytes added in v1.0.0

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

func PublicKeyFromString added in v1.0.0

func PublicKeyFromString(text string) (PublicKey, error)

func (PublicKey) Address

func (pb PublicKey) Address() Address

func (*PublicKey) EqualsTo

func (pb *PublicKey) EqualsTo(right PublicKey) bool

func (PublicKey) MarshalCBOR

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

func (PublicKey) MarshalJSON

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

func (PublicKey) MarshalText added in v1.0.0

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

func (PublicKey) RawBytes

func (pb PublicKey) RawBytes() []byte

func (*PublicKey) SanityCheck

func (pb *PublicKey) SanityCheck() error

func (PublicKey) String

func (pb PublicKey) String() string

func (*PublicKey) UnmarshalCBOR added in v0.9.1

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

func (*PublicKey) UnmarshalJSON added in v1.0.0

func (pb *PublicKey) UnmarshalJSON(bz []byte) error

func (*PublicKey) UnmarshalText added in v1.0.0

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

func (*PublicKey) Verify

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

type SignableMsg

type SignableMsg interface {
	SignBytes() []byte
	SetSignature(sig Signature)
	SetPublicKey(pub PublicKey)
}

type Signature

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

func Aggregate added in v1.0.0

func Aggregate(sigs []Signature) Signature

func SignatureFromRawBytes added in v1.0.0

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

func SignatureFromString added in v1.0.0

func SignatureFromString(text string) (Signature, error)

func (Signature) EqualsTo

func (sig Signature) EqualsTo(right Signature) bool

func (Signature) Fingerprint added in v1.0.0

func (sig Signature) Fingerprint() string

func (Signature) MarshalCBOR

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

func (Signature) MarshalJSON

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

func (Signature) MarshalText added in v1.0.0

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

func (Signature) RawBytes

func (sig Signature) RawBytes() []byte

func (Signature) SanityCheck

func (sig Signature) SanityCheck() error

func (Signature) String

func (sig Signature) String() string

func (*Signature) UnmarshalCBOR added in v0.9.1

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

func (*Signature) UnmarshalJSON added in v1.0.0

func (sig *Signature) UnmarshalJSON(bz []byte) error

func (*Signature) UnmarshalText added in v1.0.0

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

type Signer

type Signer interface {
	Address() Address
	PublicKey() PublicKey
	SignData(data []byte) Signature
	SignMsg(msg SignableMsg)
}

func GenerateTestSigner added in v1.0.0

func GenerateTestSigner() Signer

--------- For tests

func NewSigner

func NewSigner(pv PrivateKey) Signer

Jump to

Keyboard shortcuts

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