BSV.Auth.Certificate (bsv_sdk v1.1.0)

Copy Markdown View Source

BRC-31 identity certificate.

A certificate binds a subject's public key to a set of encrypted fields, signed by a certifier. Fields are encrypted with per-field symmetric keys.

Binary format: type (32 bytes) || serial (32 bytes) || subject (33 bytes) || certifier (33 bytes) || revocation_outpoint (36 bytes) || field_count (varint) || fields... || [sig_len (varint) || signature]

Summary

Functions

Deserialize a certificate from binary format.

Get the encryption protocol and key ID for a certificate field.

Sign the certificate using the certifier's wallet (ProtoWallet). Returns a new certificate with the signature set.

Serialize the certificate to binary format.

Verify the certificate signature.

Types

t()

@type t() :: %BSV.Auth.Certificate{
  cert_type: String.t(),
  certifier: BSV.PublicKey.t(),
  fields: %{required(String.t()) => String.t()},
  revocation_outpoint: String.t(),
  serial_number: String.t(),
  signature: binary(),
  subject: BSV.PublicKey.t()
}

Functions

from_binary(arg1)

@spec from_binary(binary()) :: {:ok, t()} | {:error, String.t()}

Deserialize a certificate from binary format.

get_encryption_details(field_name, serial_number)

@spec get_encryption_details(String.t(), String.t()) ::
  {BSV.Wallet.Types.Protocol.t(), String.t()}

Get the encryption protocol and key ID for a certificate field.

sign(cert, wallet)

@spec sign(t(), BSV.Wallet.ProtoWallet.t()) :: {:ok, t()} | {:error, String.t()}

Sign the certificate using the certifier's wallet (ProtoWallet). Returns a new certificate with the signature set.

to_binary(cert, include_signature \\ true)

@spec to_binary(t(), boolean()) :: {:ok, binary()} | {:error, String.t()}

Serialize the certificate to binary format.

verify(cert)

@spec verify(t()) :: {:ok, boolean()} | {:error, String.t()}

Verify the certificate signature.