Innovation Blockchain

Documentation · Coston2 testnet prototype · invented data

Documentation Contracts

Contracts

Two small contracts carry the gate. The proof registry is a notice board for signed records, with no owner. The loan vault belongs to the lender, who pins the one inspector key and the one schedule it accepts.

Status. ProofRegistryV2 and LoanVaultV2 are tested on a local chain. The owner has not deployed them on Coston2. The pair that is on Coston2 is registry v1, the earlier demo, described in the second half of this page. Both vaults are mocks: the credit limit and the draws are plain numbers, and no token or value moves.

The proof registry: ProofRegistryV2#

A notice board. It has no owner, no submitter, no constructor argument, no admin function and no upgrade hook. Anyone may relay a record. The registry recomputes the digest from the fields it is given, checks the signature over that digest, and files the record under the signing address: one slot per facility and signer.

It does not say who is an inspector. A signature shows who issued a record and that no field changed afterwards. It does not show that the facts in the record are true.

FunctionWhoWhat
submit(facilityKey, record, signer, signature)AnyoneStores the record in the slot of that facility and signer, if every rule below holds
revoke(signer, signature)AnyoneRevokes a key for good. The signature must be the signer's own, over revocationDigest(signer)
recordDigest(facilityKey, record)Anyone, a pure readSHA-256 over the record tag, the facility key and the 13 fields: 480 bytes
revocationDigest(signer)Anyone, a pure readSHA-256 over the revocation tag and the address: 64 bytes
latest(facilityKey, signer)AnyoneThe stored record, its digest (recomputed, not stored) and whether one exists
status(facilityKey, signer)AnyoneThe effective result. No record, a record past its valid-until, or a revoked signer reads as FAIL
isFresh(facilityKey, signer)AnyoneTrue when a record exists, is not past its valid-until and the signer is not revoked
isRevoked(signer), revokedAt(signer)AnyoneWhether a key was revoked, and the block time when

The record on chain#

Thirteen fields, in exactly the order of the digest, so the digest is one encoding of the struct.

FieldType
inspectorKeybytes32, SHA-256 of the inspector id
scheduleHash, reportHashbytes32
inspectionDate, issuedAt, validUntiluint64, unix seconds
scheduled, matched, sighted, exceptionsuint32
proceduresuint16, bit 0 = procedure 6.1 up to bit 7 = procedure 6.8
engagementTypeF = 0, Q = 1, E = 2
resultNONE = 0 (never stored), PASS = 1, PASS_WITH_EXCEPTIONS = 2, FAIL = 3

What the registry refuses#

submit reverts with the first of these that applies, in this order. Nothing is stored on a revert.

OrderErrorWhen
1ZeroFacilityKeyThe facility key is zero
2ZeroInspectorKeyinspectorKey is zero
3ResultNoneThe result is NONE
4BadSignatureLengthThe signature is not 65 bytes. An unsigned record stops here
5BadSignatureThe last byte is not 27 or 28, s is above half the curve order, or no address can be recovered
6SignerMismatchThe signature does not recover to signer. Any field changed after signing ends here, and so does a signature by another key
7SignerRevokedThe signer has been revoked
8IssuedInFutureissuedAt is more than 15 minutes ahead of the block time
9InspectionAfterIssueinspectionDate is more than one day after issuedAt
10ValidUntilBeforeInspectionvalidUntil is earlier than inspectionDate
11ValidityTooLongvalidUntil is more than 105 days after inspectionDate
12NoProceduresprocedures is zero
13UnknownProcedureprocedures has a bit above bit 7
14MatchedExceedsScheduledmatched is above scheduled
15SightedExceedsScheduledsighted is above scheduled
16SightedWithoutProceduresighted is not zero and procedure 6.3 is not listed
17EmptyScheduleA PASS or PASS_WITH_EXCEPTIONS with scheduled zero
18InconsistentPassA PASS with exceptions, or with matched below scheduled
19NotNewerThanStoredissuedAt is not later than the stored record of this signer for this facility

A result or engagement type outside the allowed values reverts while the call data is decoded, with no named error.

There is no check that a record is still inside its validity. A FAIL must be able to land late. A late PASS is stored too, and reads as stale.

revoke refuses BadSignatureLength, BadSignature, SignerMismatch and AlreadyRevoked. A revocation is permanent. A lost key cannot be revoked. See Keys.

Constants#

ConstantValueMeaning
RECORD_TAGSHA-256 of the text ibc-proof-record/1Word 0 of the record digest
REVOKE_TAGSHA-256 of the text ibc-key-revocation/1Word 0 of the revocation digest
MAX_VALIDITY105 days (9,072,000 seconds)The longest time from inspectionDate to validUntil
CLOCK_TOLERANCE15 minutes (900 seconds)How far ahead of the block time issuedAt may be
DATE_TOLERANCE1 dayHow far ahead of issuedAt the inspection date may be. It covers a site east of UTC
KNOWN_PROCEDURES0x00ffProcedures 6.1 to 6.8
PROCEDURE_SIGHTING0x0004Bit 2: procedure 6.3, physical sighting

Events: ProofSubmitted(facilityKey, signer, inspectorKey, digest, result, relayer) and KeyRevoked(signer, revokedAt, relayer). The relayer has no standing.

The lender's vault: LoanVaultV2#

A mock loan facility for one facility. What it shows is the gate, and that the gate belongs to the lender. Nobody else can open a draw: not the registry, not a relayer, not the borrower. A record signed by any other address than the pinned one is not read.

Fixed at deployment: registry, facilityKey, lender, borrower, creditLimit. The constructor takes, in this order: registry, facilityKey, lender, borrower, creditLimit, inspector, scheduleHash, maxRecordAge, requiredProcedures, allowDrawWithExceptions. It refuses a zero address, a zero facility key, a zero schedule hash, and a requiredProcedures of zero or with a bit above bit 7.

Only the lender can change these. Each change emits an event.

SettingCallMeaning
inspectorsetInspector(address)The one signing address whose records the vault reads. Take it from the engagement letter
scheduleHashsetScheduleHash(bytes32)The collateral schedule the loan was made against
maxRecordAgesetMaxRecordAge(uint64)Longest age in seconds from inspectionDate. Zero means no limit beyond validUntil
requiredProceduressetRequiredProcedures(uint16)The procedures a record must cover. Never zero
allowDrawWithExceptionssetAllowDrawWithExceptions(bool)Whether PASS_WITH_EXCEPTIONS allows a draw
pausedsetPaused(bool)While true, every draw is refused. Repayment stays open
secondFactsetSecondFact(address)A contract that must confirm a second fact about the record. Zero means none
FunctionWhoWhat
draw(amount)The borrowerRecords a draw, or reverts with a named error
repay(amount)The borrowerA mock. The borrower reports the repayment itself. Nothing checks it, and it is not gated by the proof or the pause
canDraw(amount)AnyoneWhether a draw would go through, and the reason if not
drawRefusal(amount)AnyoneThe same check as a code, for other contracts
available()AnyoneThe credit limit minus the drawn amount

What the vault refuses#

The reason is the first of these that applies, in this order.

What the vault checks before a draw draw(amount) called by the borrower Is the amount above zero? ZeroAmount reason ZERO_AMOUNT Is the vault open, not paused by the lender? VaultPaused reason PAUSED Is there a record signed by the pinned key? ProofMissing reason NO_RECORD Is the pinned key not revoked? InspectorRevoked INSPECTOR_REVOKED Does the schedule hash equal the pinned one? ScheduleMismatch SCHEDULE_MISMATCH Inside valid-until and the lender’s maximum age? ProofStale reason STALE Is the result other than FAIL? ProofFailed reason FAILED Are all required procedures covered? ScopeTooNarrow SCOPE_TOO_NARROW PASS, or exceptions allowed by the lender? ProofHasExceptions EXCEPTIONS_NOT_ALLOWED No second fact set, or it holds? SecondFactMissing SECOND_FACT_MISSING Within the credit limit? CreditLimitExceeded OVER_CREDIT_LIMIT Draw allowed event DrawAllowed no yes no yes no yes no yes no yes no yes no yes no yes no yes no yes no yes
What the vault checks before a draw. LoanVaultV2. The checks run in this order. The first one that fails refuses the draw with the error on the right.
The same flow in words
  1. The amount must be above zero, or the draw reverts with ZeroAmount.
  2. The lender must not have paused the vault, or VaultPaused.
  3. The registry must hold a record for the facility in the slot of the pinned signing address, or ProofMissing. A record signed by any other address is not read.
  4. The pinned address must not be revoked, or InspectorRevoked.
  5. The record’s schedule hash must equal the one the lender pinned, or ScheduleMismatch.
  6. The block time must not be past the record’s valid-until, or past the inspection date plus the lender’s maximum age, or ProofStale. No transaction is needed for a record to go stale: the clock does it.
  7. The result must not be FAIL, or ProofFailed.
  8. The record must cover every procedure the lender requires, or ScopeTooNarrow.
  9. A PASS_WITH_EXCEPTIONS record lets a draw through only if the lender allowed it, or ProofHasExceptions.
  10. If the lender named a second-fact contract, it must answer true for this record’s digest, or SecondFactMissing.
  11. The amount must fit under the credit limit, or CreditLimitExceeded.
  12. Otherwise the draw goes through and the vault emits DrawAllowed with the record’s digest and the pinned address.
OrderReason from canDrawError from drawWhen
1ZERO_AMOUNTZeroAmountThe amount is zero
2PAUSEDVaultPausedThe lender has paused the vault
3NO_RECORDProofMissingThe registry holds no record signed by the pinned address for this facility
4INSPECTOR_REVOKEDInspectorRevokedThe pinned address has been revoked
5SCHEDULE_MISMATCHScheduleMismatchThe record's scheduleHash is not the pinned one
6STALEProofStaleThe block time is past validUntil, or past inspectionDate plus maxRecordAge
7FAILEDProofFailedThe result is FAIL
8SCOPE_TOO_NARROWScopeTooNarrowThe record does not cover every required procedure
9EXCEPTIONS_NOT_ALLOWEDProofHasExceptionsThe result is PASS_WITH_EXCEPTIONS and the lender has not allowed it
10SECOND_FACT_MISSINGSecondFactMissingA second-fact contract is set and does not answer true for this record's digest
11OVER_CREDIT_LIMITCreditLimitExceededThe amount is above what is left of the credit limit

The second fact#

ISecondFact is one read function: holds(facilityKey, recordDigest). When the lender names such a contract, the vault asks it about the record it is reading, by that record's digest.

Nothing implements ISecondFact yet, except mocks used in the tests. The Flare Confidential Compute extension is planned to become an implementation in a later package. See FCC extension.

Design points#

Limits of the signed-record pair#

The wider picture is on Who is trusted for what.

Tests#

The Hardhat suite has 126 tests for both pairs, as measured on 23 November 2026: 79 for the signed-record pair, which read the shared test vectors, and 47 for registry v1. A further 22 end-to-end cases run registry v1 and its vault behind the extension's contract and a mock FlareTeeManager (Foundry). The runner runs both suites every cycle.

Registry v1 and its vault, the earlier demo shown on Coston2#

The rest of this page describes ProofRegistry and MockLoanVault, as deployed on Coston2 on 22 November 2026. They are kept unchanged as a dated demo. Their addresses are on Addresses and reference.

ProofRegistry stores one record per facility: the latest one. One address, the submitter, may post records. It checks no signature and does not recompute the digest. Its owner can change the submitter at any time. In the demo the submitter is the extension's contract, so a record reaches the registry only with a test machine's signature behind it.

FunctionWhoWhat
submit(facilityKey, record)The submitterStores the record as the facility's latest, if every rule below holds
latest(facilityKey)AnyoneThe stored record, and whether one exists
status(facilityKey)AnyoneThe effective result: a record past its valid-until date reads as FAIL
isFresh(facilityKey)AnyoneTrue while a record exists and is inside its valid-until date
setSubmitter(address)The ownerChanges who may post

What registry v1 refuses#

RuleError
Only the submitter postsNotSubmitter
A record needs a facility key and a digestZeroFacilityKey, ZeroRecordDigest
A record needs a resultResultNone
The valid-until date is not before the inspection dateValidUntilBeforeInspection
The inspection date is not more than a day in the futureInspectionDateInFuture
No rollback: a record dated before the stored one is refusedOlderThanStoredRecord
No replay: each record digest is accepted onceRecordAlreadyPosted
Matched units cannot exceed scheduled unitsMatchedExceedsScheduled

A record with the same date as the stored one is accepted, so a correction can be posted the same day as a new record with a new digest. A FAIL for the record that is stored now may always land, so a later failed check of the same record closes the gate, while a PASS for a used digest stays refused.

The v1 vault#

MockLoanVault is bound to one registry, one facility and one borrower when it is deployed.

FunctionWhoWhat
draw(amount)The borrowerDraws, or reverts with the reason
repay(amount)The borrowerLowers the drawn amount
canDraw(amount)AnyoneWhether a draw would go through, and the reason if not
setAllowDrawWithExceptions(bool)The ownerWhether a PASS_WITH_EXCEPTIONS record lets a draw through
Reason from canDrawError from drawMeaning
NO_RECORDProofMissingThe registry holds no record for the facility
STALEProofStaleThe record is past its valid-until date
FAILEDProofFailedThe latest record is a FAIL
EXCEPTIONS_NOT_ALLOWEDProofHasExceptionsThe record has exceptions and this vault does not lend on them
OVER_CREDIT_LIMITCreditLimitExceededThe amount does not fit under the credit limit

Trust that remains in v1#

These are the gaps the signed record closes. See Who is trusted for what.