1. Overview
Project name: MatchLock
One-sentence summary: A permissively licensed CKB lock/type script library, with an SDK and documentation, that lets any CKB project add private-until-match/reveal bilateral commitments and atomic conditional settlement to its own application.
License: MIT OR Apache-2.0 for all scripts, SDK, docs, and demo code
Repository: GitHub - Fizan324926/MatchLock: Project repository for MatchLock · GitHub
Team and maintainer: Fizan
2. Problem
In bilateral transactions such as OTC trades and private asset sales, parties typically have to reveal order parameters (asset, size, price) before the counterparty’s commitment is assured. On CKB, this creates information leakage and front-running risk when a deal fails to settle.
Developers building OTC or private execution applications today must write their own commitment and hold lock/type scripts from scratch, with no shared implementation to rely on. This duplicates effort, multiplies the places funds can be lost to bugs, and leaves applications unable to share tooling. CKB lacks an open, documented, tested building block for this.
3. Solution
We propose a standardized, modular CKB script primitive for hash-committed bilateral commitments and conditional hold/settlement. The project delivers an open-source CKB-VM script library and a developer SDK, published under a permissive license with a versioned interface spec. Any dApp or protocol that needs private-until-reveal order matching or atomic bilateral settlement can integrate it rather than rebuilding it, reducing duplicated development and giving the ecosystem a common, documented starting point. The scripts are unaudited and intended for testnet; ZK-based matching is listed as future work.
The deliverables come in three layers:
- Core scripts (Rust, CKB-VM). Lock/type scripts covering hash-committed locks, reveal-and-match logic (each party reveals terms, and the script verifies them against the commitments and a declared matching predicate), and timelocked hold and settlement with deterministic settle or refund paths.
- SDK (TypeScript). Helpers to build commitments, construct and sign the transactions, and parse cell state, so integrators do not need to touch script internals. Includes the interface spec and an integration guide so other CKB projects can reuse it freely under the license.
- Reference demo. A minimal web page showing two wallets completing and aborting a deal. It exists to prove the library works, not as the main product.
How it works
- Each party publishes a hash commitment to its terms, H(terms || salt), in a cell, and locks its funds under the script.
- During the reveal window, each party reveals its terms and salt. The script checks that each reveal matches its commitment.
- The script then evaluates a declared matching predicate (for example, prices cross and amounts are complementary). If it holds, both sides settle in one atomic transaction.
- If a party fails to reveal before the timeout, or the predicate fails, funds are refundable under the timeout path.
What is and is not private (stated precisely)
Phase
Hidden
Visible on-chain
After commit
Terms (price, size, asset details)
Commitment hashes, deposit amounts, addresses, timing
After reveal
Nothing
Terms of both parties
Aborted before reveal
Terms stay hidden
Commitments, deposits, refund
Revealed, no match
Nothing
Terms of both parties, refund
This is a commit-reveal scheme, not zero-knowledge. It protects terms from observers and from the counterparty until both have committed, which prevents last-look and front-running on terms. It does not hide terms once a reveal occurs, and it does not hide that a deal exists or the deposit size.
Out of scope for this grant (documented as future work): zero-knowledge proofs of matching, where terms stay hidden even on a successful match or a failed predicate. This needs proof verification inside CKB-VM and is a separate research effort. The script interface is designed so a ZK verifier can be swapped in later without changing integrators’ code.
4. Open source benefits
- Open by default. Permissive license, public repo from day one, no paid tier, no admin keys, no protocol fees, no permissioned access.
- Reusable without asking. Other projects can call the scripts by code hash, import the SDK, or fork the code. The on-chain interface (cell data layout, script args, error codes) is specified in a versioned document.
- Reduces duplicated work. One tested implementation replaces many ad hoc ones.
- Teaches the ecosystem. Architecture write-up on Nervos Talk, a developer guide, and an integration walkthrough.
- Maintained. The maintainer commits to bug-fix and compatibility updates for 12 months after delivery, with security issues handled through a published disclosure contact.
5. Alignment with Nervos / Spark
The design uses CKB’s Cell model and custom lock scripts directly: commitment and deposit live in cells, state transitions are validated by script, and settlement is a single atomic transaction. It demonstrates a pattern other builders can copy for conditional, multi-party flows.
Related work
MatchLock complements Invisibook, a privacy-preserving order-book L2 appchain proposed to the CKB Community Fund DAO. The two differ in layer, scope, and privacy goal:
- Layer: Invisibook is an L2 appchain with its own consensus. MatchLock is a set of L1 scripts that any CKB application can call.
- Trade shape: Invisibook targets many-to-many order-book trading. MatchLock targets bilateral deals between two known parties.
- Privacy goal: Invisibook aims to hide order sizes in an ongoing market. MatchLock hides terms only until both parties have committed, then reveals them at settlement.
Because MatchLock is a reusable library, projects like Invisibook could adopt it for L1 settlement steps rather than rebuilding them.
6. Budget
Total requested: $850 USD (equivalent in CKB at the official approval price snapshot).
Milestone
Deliverables
Allocation
1. Core scripts
Rust scripts for commit, reveal, settle, and timeout refund; unit and integration tests; Testnet deployment; interface spec v0.1
$400
2. SDK and integration docs
Minimal TypeScript SDK; developer guide with an integration example; Nervos Talk write-up
$250
3. Demo, testing, report
Minimal two-wallet demo page; Testnet simulations of success, abort, and timeout; security notes and known limitations; completion report
$200
Total
$850
The frontend is deliberately the smallest part of the work. Most of the budget goes to the reusable scripts, SDK, and docs.
7. Timeline
Milestone 1 (Weeks 1-3): Core scripts and Testnet deployment Deliverables: scripts and tests in the public repo, deployed to Testnet, interface spec published.
Milestone 2 (Weeks 4-5): SDK and documentation Deliverables: SDK package, developer guide with integration example, architecture write-up on Nervos Talk.
Milestone 3 (Weeks 6-7): Demo, testing, and final report Deliverables: demo page, recorded walkthrough, test results, limitations and threat-model notes, Spark completion report.
8. Risks and Limitations
- Not audited. Scripts handle funds. Delivery includes a self-review and a clear “unaudited, Testnet only” notice. A third-party audit is recommended before any Mainnet use and is not funded here.
- Reveal exposes terms. Commit-reveal cannot keep terms private after a successful reveal. This is documented, and ZK matching is listed as future work.
- Griefing by non-reveal. A party can commit and never reveal. The timeout and refund path limits fund loss, and the guide documents mitigations such as small bonds.
- Scope. The budget covers the scoped design above, not a ZK system.
- Public metadata. Wallet addresses, deposit amounts, and timing are visible on-chain and can reveal information about a deal even while terms are hidden. The docs will describe mitigations.
9. How to Verify
- Public repositories: scripts, SDK, integration example, and demo, all under the stated license.
- Testnet deployment: published script code hashes and sample transactions for success, abort, and timeout paths.
- Tests: test suite runnable by reviewers with a single documented command.
- Documentation: interface spec, developer guide, and Nervos Talk write-up.
- Recorded demo: full lifecycle of a matched deal and an aborted deal, including what is visible on-chain at each step.