Documentation ¶
Index ¶
Constants ¶
const BoxNonceSize = 24
const PrivateKeySize = 64
const PublicKeySize = 32
Variables ¶
var ( ErrBadPrivateKeySize = fmt.Errorf("bad x25519 private key size") ErrBadPrivateKeyBase64Format = fmt.Errorf("bad x25519 private key base64 format") )
var ( ErrBadPublicKeySize = fmt.Errorf("bad x25519 public key size") ErrBadPublicKeyBase64Format = fmt.Errorf("bad x25519 public key base64 format") )
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 ¶
MarshalJSON encodes the base64 value of a box nonce.
func (*BoxNonce) UnmarshalJSON ¶
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 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 ¶
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 NewPublicKeyFromBase64 ¶
PublicKey constructor from a base64 string.
func (PublicKey) MarshalJSON ¶
MarshalJSON encodes the base64 value of an x25519 public key.
func (*PublicKey) UnmarshalJSON ¶
UnmarshalJSON accepts a base64 value to load an x25519 public key.