Univrse.Envelope (Univrse v0.2.0) View Source
An Envelope is a structure for encoding any arbitrary data payload for data interchange and/or storage.
An Envelope consists of a set of headers and a data payload. Optionally one or
more Univrse.Signature.t/0
structures may be used to protect data integrity with
digital signature and MAC algorithms. And optionally, one or more Univrse.Recipient.t/0
structures may be used to ensure confidentiality of the data payload using
encryption algorithms.
A Univrse Envelope can be serialised into several formats appropriate for data interchange or storage.
- CBOR encoding
- String encoding
- Bitcoin script
Link to this section Summary
Functions
Decodes the given binary into an Envelope structure.
Decodes the given binary into an Envelope structure, using the specified
t:encoding()
.
Decodes the given CBOR encoded payload and puts it in the envelope struct.
Decrypts the envelope payload by first decrypting the content key for the recipient at the specified index with the given key.
Decodes the Envelope into a binary using the specified t:encoding()
.
CBOR encodes the Envelope payload and returns the encoded binary.
Parses the given Bitcoin Script and returns an Envelope structure.
Pushes the given t:Signature.t
or t:Recipient.t
into the Envelope.
Encodes the envelope into a valid Univrse OP_RETURN script and returns the script.
Wraps the given payload and headers in a new Envelope structure.
Link to this section Types
Specs
encoding() :: :cbor | :base64
Envelope encoding
Specs
t() :: %Univrse.Envelope{ header: Univrse.Header.t(), payload: any(), recipient: nil, signature: Univrse.Signature.t() | [Univrse.Signature.t()] | nil }
Envelope struct
Link to this section Functions
Specs
Decodes the given binary into an Envelope structure.
Automatically detects the correct encoding from the binary, assuming it is
a supported t:encoding()
.
Specs
Decodes the given binary into an Envelope structure, using the specified
t:encoding()
.
Specs
Decodes the given CBOR encoded payload and puts it in the envelope struct.
Specs
Decrypts the envelope payload by first decrypting the content key for the recipient at the specified index with the given key.
The envelope must contain multiple recipients.
Specs
Decodes the Envelope into a binary using the specified t:encoding()
.
Default encoding is :cbor
.
Specs
CBOR encodes the Envelope payload and returns the encoded binary.
Specs
parse_script(BSV.Script.t()) :: {:ok, t()} | {:error, any()}
Parses the given Bitcoin Script and returns an Envelope structure.
Specs
push(t(), Univrse.Signature.t() | Univrse.Recipient.t()) :: t()
Pushes the given t:Signature.t
or t:Recipient.t
into the Envelope.
Specs
to_script(t(), boolean()) :: BSV.Script.t()
Encodes the envelope into a valid Univrse OP_RETURN script and returns the script.
Specs
wrap(any(), map() | Univrse.Header.t()) :: t()
Wraps the given payload and headers in a new Envelope structure.