Documentation

CslibFrontier.Crypto.Protocols.AnonymousToken.Credit

Extracted certified-state credit accounting #

An ACT state carries a nullifier, a context, a committed credit t, and an issuer-granted refund x. Its effective balance is t + x; spending d replaces it with committed credit t + x - d and a newly granted refund ([ZPS26], Overview and Spending). target composes commitment of (nullifier, context, credit) with certification of its refund. It can be supplied directly to the structured-target experiment and explicit reductions in AnonymousToken.Basic.

The ledger here is extracted certified-state bookkeeping: it knows the semantic states issued by the authority. Its spend operation looks up the presented state, checks the range, atomically records the spent nullifier, and adds the successor. spend_conserves proves exact conservation of issued credit, paid credit, and the sum of remaining certificates. Repeated nullifiers need not be fresh on issuance: they strand certificates, since every subsequent spend with that nullifier is rejected. Counting stranded certificates only overestimates redeemable credit. The arithmetic uses natural numbers; the protocol's upper bounds on credit are additional restrictions on this ledger's permitted transitions.

This is an original accounting step, not a public implementation of the private ACT verifier. Relating a real adaptive proof transcript to this extracted ledger requires witness extraction and semantic certification; the explicit certification reduction is in Basic, while the full VOLE/random-oracle extraction and runtime certificates remain tracked in issue #7068.

Main definitions #

Main results #

References #

structure Cslib.Crypto.AnonymousToken.Credit.Note (Nullifier Context : Type) :

The complete semantic ACT state, including the separately granted refund.

  • nullifier : Nullifier

    The identifier checked against the spent-nullifier set.

  • context : Context

    The application context bound into the state.

  • credit : ℕ

    Credit committed by the holder before the current refund is granted.

  • refund : ℕ

    Additional credit granted by the issuer and certified with the commitment.

@[instance_reducible]
instance Cslib.Crypto.AnonymousToken.Credit.instDecidableEqNote {Nullifier✝ Context✝ : Type} [DecidableEq Nullifier✝] [DecidableEq Context✝] :
DecidableEq (Note Nullifier✝ Context✝)
def Cslib.Crypto.AnonymousToken.Credit.instDecidableEqNote.decEq {Nullifier✝ Context✝ : Type} [DecidableEq Nullifier✝] [DecidableEq Context✝] (x✝ x✝¹ : Note Nullifier✝ Context✝) :
Decidable (x✝ = x✝¹)
def Cslib.Crypto.AnonymousToken.Credit.Note.balance {Nullifier Context : Type} (note : Note Nullifier Context) :

The amount a certified state authorizes, including its refund.

def Cslib.Crypto.AnonymousToken.Credit.target {Nullifier Context Opening Commitment Target : Type} (commit : Nullifier → Context → ℕ → Opening → Commitment) (tag : Commitment → ℕ → Target) (note : Note Nullifier Context) (opening : Opening) :
Target

Compose the ACT commitment and refund-binding target encoder. A commitment need not accept the refund as part of its message: tag binds that separately granted amount to the commitment.

structure Cslib.Crypto.AnonymousToken.Credit.Ledger (Nullifier Context : Type) :

Bookkeeping after extraction: issued states not yet consumed, all spent nullifiers, and the total granted and paid amounts. Several available states may share a nullifier.

  • available : List (Note Nullifier Context)

    Issued certificates that have not been selected for consumption.

  • spent : List Nullifier

    Nullifiers consumed atomically by accepted spends.

  • granted : ℕ

    Initial funding plus every issuer-granted refund.

  • paid : ℕ

    Total debit accepted by the application.

@[instance_reducible]
instance Cslib.Crypto.AnonymousToken.Credit.instDecidableEqLedger {Nullifier✝ Context✝ : Type} [DecidableEq Nullifier✝] [DecidableEq Context✝] :
DecidableEq (Ledger Nullifier✝ Context✝)
def Cslib.Crypto.AnonymousToken.Credit.instDecidableEqLedger.decEq {Nullifier✝ Context✝ : Type} [DecidableEq Nullifier✝] [DecidableEq Context✝] (x✝ x✝¹ : Ledger Nullifier✝ Context✝) :
Decidable (x✝ = x✝¹)
def Cslib.Crypto.AnonymousToken.Credit.Ledger.empty {Nullifier Context : Type} :
Ledger Nullifier Context

The ledger before any funding or spending.

def Cslib.Crypto.AnonymousToken.Credit.Ledger.outstanding {Nullifier Context : Type} (ledger : Ledger Nullifier Context) :

Total credit in remaining certificates. A certificate with a spent nullifier is included; such a certificate cannot be redeemed, so this is an upper bound on redeemable credit.

def Cslib.Crypto.AnonymousToken.Credit.Ledger.Conserves {Nullifier Context : Type} (ledger : Ledger Nullifier Context) :

All granted credit is either paid or still represented in a remaining certificate.

Instances For
    @[instance_reducible]
    instance Cslib.Crypto.AnonymousToken.Credit.Ledger.instDecidableConserves {Nullifier Context : Type} (ledger : Ledger Nullifier Context) :
    def Cslib.Crypto.AnonymousToken.Credit.Ledger.fund {Nullifier Context : Type} (ledger : Ledger Nullifier Context) (note : Note Nullifier Context) :
    Ledger Nullifier Context

    Register an issuer-funded state. Its entire effective balance is new authorized funding.

    def Cslib.Crypto.AnonymousToken.Credit.Ledger.spend {Nullifier Context : Type} [DecidableEq Nullifier] [DecidableEq Context] (ledger : Ledger Nullifier Context) (old : Note Nullifier Context) (nextNullifier : Nullifier) (debit refund : ℕ) :
    Option (Ledger Nullifier Context)

    Consume a known certified state once and create its change state. The nullifier check and the update occur in the same transition. An issuer may choose any new nullifier; choosing one already spent creates a stranded state rather than authorizing a replay.

    @[simp]

    The empty ledger has no unpaid or granted credit.

    theorem Cslib.Crypto.AnonymousToken.Credit.Ledger.fund_conserves {Nullifier Context : Type} {ledger : Ledger Nullifier Context} (hledger : ledger.Conserves) (note : Note Nullifier Context) :
    (ledger.fund note).Conserves

    Registering funding preserves conservation, including when its nullifier was already used.

    theorem Cslib.Crypto.AnonymousToken.Credit.Ledger.spend_conserves {Nullifier Context : Type} [DecidableEq Nullifier] [DecidableEq Context] {ledger next : Ledger Nullifier Context} {old : Note Nullifier Context} {nextNullifier : Nullifier} {debit refund : ℕ} (hledger : ledger.Conserves) (hstep : ledger.spend old nextNullifier debit refund = some next) :

    An accepted spend preserves credit exactly: the old state finances the debit and its change; only the new issuer refund is added to the total grant. Membership and range checks are executed by spend, rather than supplied as assumptions about the adversary.

    theorem Cslib.Crypto.AnonymousToken.Credit.Ledger.spend_eq_none_of_spent {Nullifier Context : Type} [DecidableEq Nullifier] [DecidableEq Context] (ledger : Ledger Nullifier Context) (old : Note Nullifier Context) (nextNullifier : Nullifier) (debit refund : ℕ) (hspent : old.nullifier ∈ ledger.spent) :
    ledger.spend old nextNullifier debit refund = none

    A spent nullifier is rejected even if the ledger contains another certificate with that nullifier, or the issuer later funds such a certificate.

    theorem Cslib.Crypto.AnonymousToken.Credit.Ledger.Conserves.paid_le_granted {Nullifier Context : Type} {ledger : Ledger Nullifier Context} (hledger : ledger.Conserves) :
    ledger.paid ≤ ledger.granted

    The conservation invariant bounds accepted payouts by all issuer-granted credit.