x25519

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const EncryptionCipher = "x25519-xsalsa20-poly1305"
View Source
const EncryptionNonceSize = 24

EncryptionNonceSize represents the length of the nonce used in the encryption process

View Source
const EncryptionVersion = 1
View Source
const X25519 = "X25519"

X25519 is the string representations of the X25519 scheme

Variables

This section is empty.

Functions

func NewX25519

func NewX25519() *suiteX25519

NewX25519 is responsible for instantiating a suiteX25519 component

Types

type EncryptedCryptoData

type EncryptedCryptoData struct {
	Cipher     string `json:"cipher"`
	Ciphertext string `json:"ciphertext"`
	MAC        string `json:"mac"`
}

EncryptedCryptoData holds crypto information such as the cipher used, the ciphertext itself and the authentication code

type EncryptedData

type EncryptedData struct {
	Nonce      string                  `json:"nonce"`
	Version    uint8                   `json:"version"`
	Crypto     EncryptedCryptoData     `json:"crypto"`
	Identities EncryptedDataIdentities `json:"identities"`
}

EncryptedData holds the needed information of an encrypted message required to correctly be decrypted by the recipient

func (*EncryptedData) Decrypt

func (ed *EncryptedData) Decrypt(recipientPrivateKey crypto.PrivateKey) ([]byte, error)

Decrypt returns the plain text associated to a ciphertext that was previously encrypted using the public key of the recipient

func (*EncryptedData) Encrypt

func (ed *EncryptedData) Encrypt(data []byte, recipientPubKey crypto.PublicKey, senderPrivateKey crypto.PrivateKey) error

Encrypt generates a public key encryption for a message using a recipient edwards public key and an ephemeral private key generated on the spot. The senderPrivateKey param is used to authenticate the encryption that normally should happen between two edwards curve identities.

type EncryptedDataIdentities

type EncryptedDataIdentities struct {
	Recipient        string `json:"recipient"`
	EphemeralPubKey  string `json:"ephemeralPubKey"`
	OriginatorPubKey string `json:"originatorPubKey"`
}

EncryptedDataIdentities holds the data associated with the identities involved in the encryption process - who is able to decrypt, the ephemeral public key used to encrypt, and the address of the originator of the encryption used to authenticate that indeed a message was encrypted by Bob for Alice (remember that the private key used for encryption is ephemeral - in order to avoid nonce reuses and multipurpose use of the same secret)

type PrivateKey

type PrivateKey []byte

PrivateKey is the custom type that handles a X25519 private key

func (*PrivateKey) Public

func (p *PrivateKey) Public() (PublicKey, error)

Public returns the public key associated to the current private key

type PublicKey

type PublicKey []byte

Jump to

Keyboard shortcuts

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