Skip to Content
ConceptsThe Veil ModelScore Computation

Score Computation

The score is computed from the user’s accumulated behavior data whenever recomputeAndPersistScore is triggered (during mint and renewal). The formula:


rawScore = baseScore + behaviorScore - penaltyScore
rawScore = clamp(rawScore, 0, maxScore)

Behavior score components:

ComponentFormulaConfig Param
Repayment contributionrepaymentRatio × repaymentWeightrepaymentWeight
Protocol diversity contributiondistinctProtocols × protocolWeightprotocolWeight
Tenure contributionepochsActive × tenureWeighttenureWeight

Where repaymentRatio = (onTimeRepayments / totalRepayments) × scale, computed off-circuit by the witness and verified inside the circuit with a remainder proof.

Penalty score components:

ComponentFormulaConfig Param
Liquidation penaltiesliquidationPenaltyPoints × liquidationWeightliquidationWeight
Active debt penalty activeDebtFlag × activeDebtPenaltyactiveDebtPenalty
Risk band penaltyriskBand × riskBandWeightriskBandWeight

Safety invariants enforced on-chain:

  • Event monotonicity: eventEpoch >= lastEventEpoch (prevents retroactive manipulation)
  • Replay protection: each eventId is hashed with domain tag, user, issuer, and contract address — duplicates are rejected
  • Commitment validation: both the credit score and accumulator must have valid Merkle paths in the on-chain commitment trees before and after each update
  • Score arithmetic: underflow and overflow are asserted before the final value is stored
Last updated on