nacl

package
v1.1.14 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 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 GenerateNewPrivateKey

func GenerateNewPrivateKey() PrivateKey

GenerateNewPrivateKey generates a new x25519 private key.

func NewPrivateKey

func NewPrivateKey(privateKeyBytes []byte) PrivateKey

PrivateKey constructor.

func NewPrivateKeyFromBase64

func NewPrivateKeyFromBase64(privateKeyBase64 string) PrivateKey

PrivateKey constructor from a base64 string.

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 NewPublicKeyFromBase64

func NewPublicKeyFromBase64(publicKeyBase64 string) PublicKey

PublicKey constructor from a base64 string.

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