MetamorphicLog.Commitment (metamorphic_log v0.1.0)

Copy Markdown View Source

SHA3-512 commitment verification (CONIKS value commitments).

A commitment is SHA3-512_with_context(context, opening(32 bytes) || value). Given the public context label, the 64-byte commitment, the committed value, and the 32-byte opening, verify/4 recomputes and constant-time compares.

All binary arguments are base64-encoded.

Summary

Functions

Boolean form of verify/4. Returns true only on a valid opening.

Verify that commitment opens to value under opening and context.

Functions

valid?(context, commitment_b64, value_b64, opening_b64)

@spec valid?(String.t(), String.t(), String.t(), String.t()) :: boolean()

Boolean form of verify/4. Returns true only on a valid opening.

verify(context, commitment_b64, value_b64, opening_b64)

@spec verify(
  context :: String.t(),
  commitment_b64 :: String.t(),
  value_b64 :: String.t(),
  opening_b64 :: String.t()
) :: :ok | {:error, String.t()}

Verify that commitment opens to value under opening and context.

Returns :ok or {:error, reason}.

Example

:ok = MetamorphicLog.Commitment.verify(context, commitment, value, opening)