Kinlock docs

Protocol Mechanics & Economic Model

How payment locks work mathematically, cryptographically, and economically on Stellar (Soroban). Zero custodial risk, deterministic release schedules, and transparent state transitions.

The Lock State Machine

Every lock in Kinlock begins in the Open state and follows a strictly defined, immutable lifecycle. Money can only take two exit paths: forward to the snapshotted payout address, or backward to the sender.

1. Open
Funds are deposited into the Soroban contract vault. Payout address and token are snapshotted permanently. Tranches wait for their individual unlock_at timestamps.
2. Released
Tranches are claimed by the recipient as they become due (unlock_at ≤ now < expires_at). When all tranches are released, the lock is fully closed.
3. Declined
The payee explicitly declines the lock at any time while Open. All unreleased funds return immediately to the sender.
4. Refunded
The lock passes expires_at, or the verified payee is Revoked / Suspended past a 14-day grace period. The sender reclaims 100% of the remaining balance.

Worked Economic Example: $1,200 Tuition Schedule

To understand how Kinlock operates in real financial scenarios, consider a diaspora parent sending tuition to a secondary school in Nairobi, Kenya:

If the student transfers schools after Term 1, the school releases Tranche 1 ($400) and declines the rest. The remaining $800 USDC immediately returns to the parent's wallet—with zero dispute friction or intermediary delays.

Client-Side Cryptographic Privacy

Public blockchains are pseudonymous, but financial references (e.g. invoice numbers, student IDs) are sensitive personal data. Kinlock solves this through a zero-knowledge link fragment pattern:

1. Salt Generation
The sender's browser generates 16 bytes of cryptographically secure random salt.
2. Hash Derivation
The browser computes ref_hash = sha256(reference || salt). Only this 32-byte hash is sent to the contract.
3. URL Hash Fragment
The plaintext reference and salt are formatted into the URL hash fragment: /claim/42#r=INV-2026-01&s=a1b2c3d4....
4. Server Blindness
Per RFC 3986, HTTP clients never transmit the fragment to web servers or APIs. No server, database, or analytics tracker ever sees the reference.

Soroban State TTL & Safety Margins

Soroban ledger storage entries expire unless periodically renewed. To guarantee safety: