Documentation ¶
Index ¶
Constants ¶
const EncryptionCipher = "x25519-xsalsa20-poly1305"
const EncryptionNonceSize = 24
EncryptionNonceSize represents the length of the nonce used in the encryption process
const EncryptionVersion = 1
const X25519 = "X25519"
X25519 is the string representations of the X25519 scheme
Variables ¶
This section is empty.
Functions ¶
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