Documentation
¶
Index ¶
- Constants
- Variables
- func Decrypt(ciphertext, nonce []byte, senderPub *ecdh.PublicKey, ...) ([]byte, error)
- func Encrypt(plaintext []byte, senderPriv *ecdh.PrivateKey, recipientPub *ecdh.PublicKey) ([]byte, []byte, error)
- func LoadPublicKey(pubBytes []byte) (*ecdh.PublicKey, error)
- func Seal(plaintext []byte, recipientPub *ecdh.PublicKey) ([]byte, []byte, error)
- func Unseal(encBlob, nonce []byte, recipientPriv *ecdh.PrivateKey) ([]byte, error)
- func UnwrapKey(wrappedBlob, nonce []byte, myPriv *ecdh.PrivateKey) ([]byte, error)
- func WrapKey(keyToShare []byte, recipientPub *ecdh.PublicKey) ([]byte, []byte, error)
- type KeyPair
Constants ¶
const KeySize = chacha20poly1305.KeySize
Variables ¶
var ( ErrInvalidKeySize = errors.New("key must be exactly 32 bytes") ErrUnwrapFailed = errors.New("unwrapped data is not a valid key") )
Functions ¶
func Decrypt ¶
func Decrypt(ciphertext, nonce []byte, senderPub *ecdh.PublicKey, recipientPriv *ecdh.PrivateKey) ([]byte, error)
Decrypt decrypts data using recipient's private key and sender's public key pair.
func Encrypt ¶
func Encrypt(plaintext []byte, senderPriv *ecdh.PrivateKey, recipientPub *ecdh.PublicKey) ([]byte, []byte, error)
Encrypt encrypts data using sernder's private key and recipient's public key pair.
func LoadPublicKey ¶
LoadPublicKey converts raw bytes back into a Public Key object.
func Seal ¶
Seal encrypts a message anonymously. It generates an temporary key pair, so the sender does not need an identity.
Output Structure: [EphemeralPublicKey (32 bytes)] + [VaultBlob (Nonce + Ciphertext)]
func Unseal ¶
func Unseal(encBlob, nonce []byte, recipientPriv *ecdh.PrivateKey) ([]byte, error)
Unseal decrypts an anonymously encrypted message. It extracts the temprorary public key from the header and uses it to derive the decryption key.
Types ¶
type KeyPair ¶
type KeyPair struct {
Public *ecdh.PublicKey
Private *ecdh.PrivateKey
}
func GenerateKeyPair ¶
GenerateKeyPair creates a fresh X25519 identity for encryption.
func LoadPrivateKey ¶
LoadPrivateKey converts raw bytes into a usable Key Pair object.