MPP.Session.Voucher (mpp v0.14.0)

Copy Markdown View Source

TIP-1034 Tempo Channel Reserve voucher and EIP-712 signature verification.

The signed type is Voucher(bytes32 channelId,uint96 cumulativeAmount) under the TIP20 Channel Reserve version 1 domain. Signatures are canonical 65-byte secp256k1 signatures, matching the contract-backed mppx voucher path.

Summary

Functions

Compute the 32-byte EIP-712 voucher signing digest.

Compute the voucher signing digest, raising ArgumentError on invalid input.

Create a validated signed voucher.

Create a signed voucher, raising ArgumentError on invalid input.

Build the EIP-712 typed data for a voucher.

Build voucher typed data, raising ArgumentError on invalid input.

Verify that a voucher signature recovers to the expected signer.

Types

t()

@type t() :: %MPP.Session.Voucher{
  channel_id: String.t(),
  cumulative_amount: non_neg_integer(),
  signature: String.t()
}

Functions

hash(voucher, escrow_contract, chain_id)

@spec hash(t(), String.t(), non_neg_integer()) :: {:ok, <<_::256>>} | {:error, term()}

Compute the 32-byte EIP-712 voucher signing digest.

hash!(voucher, escrow_contract, chain_id)

@spec hash!(t(), String.t(), non_neg_integer()) :: <<_::256>>

Compute the voucher signing digest, raising ArgumentError on invalid input.

new(opts)

@spec new(keyword()) :: {:ok, t()} | {:error, term()}

Create a validated signed voucher.

new!(opts)

@spec new!(keyword()) :: t()

Create a signed voucher, raising ArgumentError on invalid input.

typed_data(voucher, escrow_contract, chain_id)

@spec typed_data(t(), String.t(), non_neg_integer()) ::
  {:ok, Cartouche.Typed.t()} | {:error, term()}

Build the EIP-712 typed data for a voucher.

typed_data!(voucher, escrow_contract, chain_id)

@spec typed_data!(t(), String.t(), non_neg_integer()) :: Cartouche.Typed.t()

Build voucher typed data, raising ArgumentError on invalid input.

verify_signature(voucher, escrow_contract, chain_id, expected_signer)

@spec verify_signature(t(), String.t(), non_neg_integer(), String.t()) ::
  :ok | {:error, term()}

Verify that a voucher signature recovers to the expected signer.