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:
| Component | Formula | Config Param |
|---|---|---|
| Repayment contribution | repaymentRatio × repaymentWeight | repaymentWeight |
| Protocol diversity contribution | distinctProtocols × protocolWeight | protocolWeight |
| Tenure contribution | epochsActive × tenureWeight | tenureWeight |
Where repaymentRatio = (onTimeRepayments / totalRepayments) × scale, computed off-circuit by the witness and verified inside the circuit with a remainder proof.
Penalty score components:
| Component | Formula | Config Param |
|---|---|---|
| Liquidation penalties | liquidationPenaltyPoints × liquidationWeight | liquidationWeight |
| Active debt penalty | activeDebtFlag × activeDebtPenalty | activeDebtPenalty |
| Risk band penalty | riskBand × riskBandWeight | riskBandWeight |
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