nacl

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const BoxNonceSize = 24
View Source
const PrivateKeySize = 64
View Source
const PublicKeySize = 32

Variables

View Source
var (
	ErrBadPrivateKeySize         = fmt.Errorf("bad x25519 private key size")
	ErrBadPrivateKeyBase64Format = fmt.Errorf("bad x25519 private key base64 format")
)
View Source
var (
	ErrBadPublicKeySize         = fmt.Errorf("bad x25519 public key size")
	ErrBadPublicKeyBase64Format = fmt.Errorf("bad x25519 public key base64 format")
)
View Source
var (
	ErrBadNonceSize = fmt.Errorf("bad nonce size")
)

Functions

This section is empty.

Types

type BoxNonce

type BoxNonce [BoxNonceSize]byte

BoxNonce is a Nacl box nonce wrapper (24 bytes)

func (BoxNonce) MarshalJSON

func (bn BoxNonce) MarshalJSON() ([]byte, error)

MarshalJSON encodes the base64 value of a box nonce.

func (BoxNonce) String

func (bn BoxNonce) String() string

String returns the base64 representation.

func (*BoxNonce) UnmarshalJSON

func (bn *BoxNonce) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts a base64 value to load a box nonce.

type PrivateKey

type PrivateKey [PrivateKeySize]byte

PrivateKey is an x25519 private key wrapper (64 bytes).

func NewPrivateKey

func NewPrivateKey(privateKeyBytes []byte) PrivateKey

PrivateKey constructor.

func (PrivateKey) GetPublicKey

func (pk PrivateKey) GetPublicKey() PublicKey

GetPublicKey returns the underlying x25519 public key.

func (PrivateKey) Open

func (pk PrivateKey) Open(encryptedMessage []byte, nonce BoxNonce, senderPublicKey PublicKey) ([]byte, bool)

Open decrypts an encrypted message with the appropriate sender information.

func (PrivateKey) Seal

func (pk PrivateKey) Seal(message []byte, recipientPublicKey PublicKey) ([]byte, BoxNonce, error)

Seal encrypts a plain text message decipherable afterwards by the recipient private key.

func (PrivateKey) String

func (pk PrivateKey) String() string

String returns the base64 representation.

type PublicKey

type PublicKey [PublicKeySize]byte

PublicKey is an x25519 public key wrapper (32 bytes).

func NewPublicKey

func NewPublicKey(publicKeyBytes []byte) PublicKey

PublicKey constructor.

func (PublicKey) MarshalJSON

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

MarshalJSON encodes the base64 value of an x25519 public key.

func (PublicKey) String

func (pk PublicKey) String() string

String returns the base64 representation.

func (*PublicKey) UnmarshalJSON

func (pk *PublicKey) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts a base64 value to load an x25519 public key.

Jump to

Keyboard shortcuts

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