Univrse.Signature.sign
You're seeing just the function
sign
, go back to Univrse.Signature module for more information.
Specs
sign( Univrse.Envelope.t(), Univrse.Key.t() | [Univrse.Key.t()] | [{Univrse.Key.t(), map()}], map() ) :: {:ok, Univrse.Envelope.t()} | {:error, any()}
Signs the Envelope payload using the given key or array of keys.
A map of headers must be given including at least the signature alg
value.
Where a list of keys is given, it is possible to specify different algorithms for each key by giving a list of tuple pairs. The first element of each pair is the key and the second is a map of headers.
Examples
Creates a signature using a single key:
Signature.sign(env, oct_key, %{"alg" => "HS256"})
Creates multiple signatures using the same algorithm:
Signature.sign(env, [oct_key, app_key], %{"alg" => "HS256"})
Creates multiple signatures using different algorithms:
Signature.sign(env, [
oct_key,
{ec_key_1, %{"alg" => "ES256K"}},
{ec_key_2, %{"alg" => "ES256K"}}
], %{"alg" => "HS256"})