Univrse.Key (Univrse v0.2.0) View Source
A Univrse Key is a CBOR data structure that represents a cryptographic key. Univrse Keys closely mirror JSON Web Keys, and it should prove simple to convert keys between the two specifications.
Keys are used in the Univrse.Signature.t/0
and Univrse.Recipient.t/0
specifications.
Link to this section Summary
Functions
Decodes the given CBOR encoded key into a Key struct.
Encodes the Key as a CBOR encoded binary.
Securely generates a new key of the given t:init_params
.
Returns a public key from the current key, which can be safely shared with other parties.
Link to this section Types
Specs
ec_params() :: %{crv: String.t(), x: binary(), y: binary(), d: binary()} | %{crv: String.t(), x: binary(), y: binary()}
Elliptic curve key params
Specs
Key initialisation params
Specs
oct_params() :: %{k: binary()}
Octet sequence key params
Specs
t() :: %Univrse.Key{params: ec_params() | oct_params(), type: String.t()}
Key struct
Link to this section Functions
Specs
Decodes the given CBOR encoded key into a Key struct.
Specs
Encodes the Key as a CBOR encoded binary.
Specs
generate_key(init_params() | t()) :: t()
Securely generates a new key of the given t:init_params
.
Supported key types
{:ec, :secp256k1}
- Eliptic curve key on thesecp256k1
curve{:oct, 128}
- Octet sequence key of 128 bits{:oct, 256}
- Octet sequence key of 256 bits{:oct, 512}
- Octet sequence key of 512 bits
Specs
Returns a public key from the current key, which can be safely shared with other parties.
Only for use with EC
key types.