Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeSharedSecret(pkh, skh S) (sharedSecret B, err E)
- func Decrypt(b64ciphertextWrapped S, conversationKey B) (plaintext S, err E)
- func DecryptNip4(content S, key B) (msg B, err E)deprecated
- func Encrypt(plaintext S, conversationKey B, applyOptions ...func(opts *Opts)) (cipherString S, err E)
- func EncryptNip4(msg S, key B) (ct B, err E)deprecated
- func GenerateConversationKey(pkh, skh S) (ck B, err E)
- func WithCustomNonce(salt B) func(opts *Opts)
- type Opts
Constants ¶
const ( MinPlaintextSize = 0x0001 // 1b msg => padded to 32b MaxPlaintextSize = 0xffff // 65535 (64kb-1) => padded to 64kb )
Variables ¶
var WithCustomSalt = WithCustomNonce
Deprecated: use WithCustomNonce instead of WithCustomSalt, so the naming is less confusing
Functions ¶
func ComputeSharedSecret ¶
func ComputeSharedSecret(pkh, skh S) (sharedSecret B, err E)
ComputeSharedSecret returns a shared secret key used to encrypt messages. The private and public keys should be hex encoded. Uses the Diffie-Hellman key exchange (ECDH) (RFC 4753).
func DecryptNip4
deprecated
func DecryptNip4(content S, key B) (msg B, err E)
DecryptNip4 decrypts a content string using the shared secret key. The inverse operation to message -> EncryptNip4(message, key).
Deprecated: upgrade to using Decrypt with the NIP-44 algorithm.
func Encrypt ¶
func Encrypt(plaintext S, conversationKey B, applyOptions ...func(opts *Opts)) (cipherString S, err E)
func EncryptNip4
deprecated
func EncryptNip4(msg S, key B) (ct B, err E)
EncryptNip4 encrypts message with key using aes-256-cbc. key should be the shared secret generated by ComputeSharedSecret.
Returns: base64(encrypted_bytes) + "?iv=" + base64(initialization_vector).
Deprecated: upgrade to using Decrypt with the NIP-44 algorithm.
func GenerateConversationKey ¶
func GenerateConversationKey(pkh, skh S) (ck B, err E)
func WithCustomNonce ¶
func WithCustomNonce(salt B) func(opts *Opts)