Nostr.Crypto (Nostr Lib v0.2.1)

View Source

Crypto related stuff

Summary

Functions

Decrypt message with ECDH from seckey and pubkey (automatically extracts IV from message)

Encrypt message with ECDH from seckey and pubkey and append randomly generated IV

Get pubkey (hex encoded) from seckey (hex encoded)

Sign binary data (hex encoded) with seckey (hex encoded)

Functions

decrypt(message, seckey, pubkey)

@spec decrypt(binary(), binary(), binary()) :: String.t()

Decrypt message with ECDH from seckey and pubkey (automatically extracts IV from message)

encrypt(message, seckey, pubkey)

@spec encrypt(String.t(), binary(), binary()) :: binary()

Encrypt message with ECDH from seckey and pubkey and append randomly generated IV

pubkey(seckey)

@spec pubkey(seckey :: binary()) :: binary()

Get pubkey (hex encoded) from seckey (hex encoded)

Example:

iex> Nostr.Crypto.pubkey("1111111111111111111111111111111111111111111111111111111111111111")
"4f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa"

sign(data, seckey)

@spec sign(data :: binary(), seckey :: binary()) :: binary()

Sign binary data (hex encoded) with seckey (hex encoded)