nacl

package
v1.4.62 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const KeyLength = 32

KeyLength is the length of keys (in bytes).

View Source
const NonceLength = 24

NonceLength is the the length of nonces (in bytes).

Variables

This section is empty.

Functions

This section is empty.

Types

type Challenge

type Challenge interface {
	ToSolve() ([]byte, Nonce)
	IsSolution([]byte, Nonce) bool
}

Challenge represents something that can be solved and solutions can be checked against.

type Nonce

type Nonce *[NonceLength]byte

Nonce represents a nonce.

func GenerateNonce added in v1.4.48

func GenerateNonce() (Nonce, error)

GenerateNonce generates a fixed number of random bytes.

func SolveChallenge added in v1.4.48

func SolveChallenge(challenge []byte, nonce Nonce, peersPublicKey *PublicKey, privateKey *PrivateKey) ([]byte, Nonce, error)

SolveChallenge attempts to solve a challenge with a given private key.

type PrivateKey

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

PrivateKey represents a private key.

func GenerateKey added in v1.4.49

func GenerateKey() (*PrivateKey, error)

GenerateKey generates a new PrivateKey.

func ParsePrivateKey added in v1.4.49

func ParsePrivateKey(raw []byte) (*PrivateKey, error)

ParsePrivateKey parses raw bytes onto a PrivateKey.

func ParsePrivateKeyB64 added in v1.4.49

func ParsePrivateKeyB64(b64 string) (*PrivateKey, error)

ParsePrivateKeyB64 parses base64-encoded bytes onto a PrivateKey.

func (*PrivateKey) B64 added in v1.4.51

func (p *PrivateKey) B64() string

B64 returns the base64-encoded private key bytes.

func (*PrivateKey) Public added in v1.4.49

func (p *PrivateKey) Public() *PublicKey

Public returns the public key corresponding to the private key.

func (*PrivateKey) Raw added in v1.4.49

func (p *PrivateKey) Raw() *[KeyLength]byte

Raw returns the address of the raw private key bytes.

type PublicKey

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

PublicKey represents a public key.

func MustParsePublicKey added in v1.4.58

func MustParsePublicKey(raw []byte) *PublicKey

MustParsePublicKey parses raw bytes onto a PublicKey or panics on error.

func ParsePublicKey added in v1.4.49

func ParsePublicKey(raw []byte) (*PublicKey, error)

ParsePublicKey parses raw bytes onto a PublicKey.

func ParsePublicKeyB64 added in v1.4.49

func ParsePublicKeyB64(b64 string) (*PublicKey, error)

ParsePublicKeyB64 parses base64-encoded bytes onto a PublicKey.

func (*PublicKey) B64 added in v1.4.51

func (p *PublicKey) B64() string

B64 returns the base64-encoded public key bytes.

func (*PublicKey) Raw added in v1.4.49

func (p *PublicKey) Raw() *[KeyLength]byte

Raw returns the address of the raw public key bytes.

type Service

type Service interface {
	PrivateKey() *PrivateKey
	NewChallengeForPeer(*PublicKey) (Challenge, error)
}

Service represents an entity capable of issuing challenges for others to solve.

func New

func New(privateKey *PrivateKey) (Service, error)

New returns a newly initialized, default Service implementation.

Jump to

Keyboard shortcuts

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