Documentation
¶
Overview ¶
Package encryption contains the message encryption schemes defined in NIP-04 and NIP-44, used for encrypting the content of nostr messages.
Index ¶
- Variables
- func Decrypt(conversationKey []byte, ciphertext string) (plaintext string, err error)
- func DecryptNip4(content, key []byte) (msg []byte, err error)
- func Encrypt(conversationKey []byte, plaintext []byte, options *EncryptOptions) (ciphertext string, err error)
- func EncryptNip4(msg, key []byte) (ct []byte, err error)
- func GenerateConversationKey(sendPrivkey []byte, recvPubkey []byte) (conversationKey []byte, err error)
- func MessageKeys(conversationKey []byte, salt []byte) ([]byte, []byte, []byte, error)
- type EncryptOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MinPlaintextSize = 0x0001 // 1b msg => padded to 32b MaxPlaintextSize = 0xffff // 65535 (64kb-1) => padded to 64kb )
Functions ¶
func Decrypt ¶
func DecryptNip4 ¶
DecryptNip4 decrypts a content string using the shared secret key. The inverse operation to message -> EncryptNip4(message, key).
func Encrypt ¶
func Encrypt(conversationKey []byte, plaintext []byte, options *EncryptOptions) (ciphertext string, err error)
func EncryptNip4 ¶
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).
func GenerateConversationKey ¶ added in v0.25.3
Types ¶
Source Files
¶
- doc.go
- nip4.go
- nip44.go
Click to show internal directories.
Click to hide internal directories.