Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateKey() (publicKey PublicKey, privateKey PrivateKey, err error)
- type KeyPair
- type PrivateKey
- func (privateKey PrivateKey) Bytes() ([]byte, error)
- func (privateKey *PrivateKey) FromBytes(bytes []byte) (consumedBytes int, err error)
- func (privateKey PrivateKey) Public() (result PublicKey)
- func (privateKey PrivateKey) Seed() *Seed
- func (privateKey PrivateKey) Sign(data []byte) (result Signature)
- func (privateKey PrivateKey) String() string
- type PublicKey
- func ParsePublicKey(marshalUtil *marshalutil.MarshalUtil) (PublicKey, error)
- func PublicKeyFromBytes(bytes []byte) (result PublicKey, consumedBytes int, err error)
- func PublicKeyFromString(s string) (publicKey PublicKey, err error)
- func RecoverKey(key, data, sig []byte) (result PublicKey, err error)
- func (publicKey PublicKey) Bytes() ([]byte, error)
- func (publicKey *PublicKey) FromBytes(bytes []byte) (int, error)
- func (publicKey PublicKey) MarshalJSON() ([]byte, error)
- func (publicKey PublicKey) String() string
- func (publicKey *PublicKey) UnmarshalBinary(bytes []byte) error
- func (publicKey *PublicKey) UnmarshalJSON(b []byte) error
- func (publicKey PublicKey) VerifySignature(data []byte, signature Signature) bool
- type Seed
- type Signature
Constants ¶
const ( PublicKeySize = ed25519.PublicKeySize SignatureSize = ed25519.SignatureSize PrivateKeySize = ed25519.PrivateKeySize SeedSize = ed25519.SeedSize )
Variables ¶
var (
ErrNotEnoughBytes = errors.New("not enough bytes")
)
Functions ¶
func GenerateKey ¶
func GenerateKey() (publicKey PublicKey, privateKey PrivateKey, err error)
GenerateKey creates a public/private key pair.
Types ¶
type KeyPair ¶
type KeyPair struct { PrivateKey PrivateKey PublicKey PublicKey }
func GenerateKeyPair ¶
func GenerateKeyPair() (keyPair KeyPair)
type PrivateKey ¶
type PrivateKey [PrivateKeySize]byte
PrivateKey is the type of Ed25519 private keys.
func GeneratePrivateKey ¶
func GeneratePrivateKey() (privateKey PrivateKey, err error)
GenerateKey creates a private key.
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(bytes []byte) (result PrivateKey, consumedBytes int, err error)
PrivateKeyFromBytes creates a PrivateKey from the given bytes.
func PrivateKeyFromSeed ¶
func PrivateKeyFromSeed(seed []byte) (result PrivateKey)
PrivateKeyFromSeed calculates a private key from a seed.
func (PrivateKey) Bytes ¶
func (privateKey PrivateKey) Bytes() ([]byte, error)
Bytes returns the privateKey in bytes.
func (*PrivateKey) FromBytes ¶
func (privateKey *PrivateKey) FromBytes(bytes []byte) (consumedBytes int, err error)
FromBytes initializes the PrivateKey from the given bytes.
func (PrivateKey) Public ¶
func (privateKey PrivateKey) Public() (result PublicKey)
Public returns the PublicKey corresponding to privateKey.
func (PrivateKey) Seed ¶
func (privateKey PrivateKey) Seed() *Seed
Seed returns the private key seed corresponding to privateKey. It is provided for interoperability with RFC 8032. RFC 8032's private keys correspond to seeds in this package.
func (PrivateKey) Sign ¶
func (privateKey PrivateKey) Sign(data []byte) (result Signature)
Sign signs the message with privateKey and returns a signature.
func (PrivateKey) String ¶
func (privateKey PrivateKey) String() string
String returns a human-readable version of the PrivateKey (base58 encoded).
type PublicKey ¶
type PublicKey [PublicKeySize]byte
PublicKey is the type of Ed25519 public keys.
func ParsePublicKey ¶
func ParsePublicKey(marshalUtil *marshalutil.MarshalUtil) (PublicKey, error)
func PublicKeyFromBytes ¶
PublicKeyFromBytes creates a PublicKey from the given bytes.
func PublicKeyFromString ¶
PublicKeyFromString parses the given string with base58 encoding and returns a PublicKey.
func RecoverKey ¶
RecoverKey makes sure that key and signature have the correct length and verifies whether sig is a valid signature of data by pub.
func (PublicKey) MarshalJSON ¶
MarshalJSON serializes public key to JSON as base58 encoded string.
func (PublicKey) String ¶
String returns a human-readable version of the PublicKey (base58 encoded).
func (*PublicKey) UnmarshalBinary ¶
func (*PublicKey) UnmarshalJSON ¶
UnmarshalJSON parses public key from JSON in base58 encoding.
type Seed ¶
type Seed struct {
// contains filtered or unexported fields
}
Seed is a generator for a deterministic sequence of KeyPairs.
func NewSeed ¶
NewSeed represents the factory method for a Seed object. It either generates a new random seed or restores an existing one from a sequence of bytes.
func (*Seed) Bytes ¶
Bytes marshals the Seed object into a sequence of Bytes that can be used to later restore the Seed by handing it into the factory method.
type Signature ¶
type Signature [SignatureSize]byte
var EmptySignature Signature
func ParseSignature ¶
func ParseSignature(marshalUtil *marshalutil.MarshalUtil) (Signature, error)
func SignatureFromBytes ¶
SignatureFromBytes creates a Signature from the given bytes.
func (Signature) String ¶
String returns a human-readable version of the Signature (base58 encoded).