nacl

package
v1.4.48 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// KeyLength is the length of keys (in bytes).
	KeyLength = 32

	// NonceLength is the the length of nonces (in bytes).
	NonceLength = 24
)

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, selfPriv PrivateKey, peerPub PublicKey) ([]byte, Nonce, error)

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

type PrivateKey

type PrivateKey *[KeyLength]byte

PrivateKey represents a private key.

type PublicKey

type PublicKey *[KeyLength]byte

PublicKey represents a public key.

type Service

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

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

func New

func New() (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