nip4

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: CC0-1.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeSharedSecret

func ComputeSharedSecret(pub string, sec string) (secret []byte, err error)

ComputeSharedSecret computes an Elliptic Curve Diffie Hellman shared secret out of one public key and another secret key.

The public key and secret key for this can be either hex or bech32 formatted, since this is easily determined by reading the first 4 bytes of the string

func Decrypt

func Decrypt(content string, key []byte) ([]byte, error)

Decrypt decrypts a content string using the shared secret key. The inverse operation to message -> Encrypt(message, key).

func Encrypt

func Encrypt(message string, key []byte) (string, error)

Encrypt 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 GenerateSharedSecret

func GenerateSharedSecret(s *secp256k1.SecretKey, p *secp256k1.PublicKey) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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