Skip to content

feat: NUT-CTF conditional tokens for prediction markets#1648

Closed
joemphilips wants to merge 3 commits intocashubtc:mainfrom
joemphilips:feat/ctf-28
Closed

feat: NUT-CTF conditional tokens for prediction markets#1648
joemphilips wants to merge 3 commits intocashubtc:mainfrom
joemphilips:feat/ctf-28

Conversation

@joemphilips
Copy link

@joemphilips joemphilips commented Feb 17, 2026

Summary

Reference implementation of NUT-CTF: Conditional Tokens for Prediction Markets.

This is a work-in-progress draft. More details to follow as the spec stabilizes.

Add mint-side support for NUT-28 (Conditional Tokens) behind the
`conditional-tokens` feature flag. This enables Cashu mints to
support prediction market use cases via DLC oracle attestations.

New crate modules and changes:
- cashu: nut28 module with types (conditions, oracle witness,
  partition validation), DLC helpers (announcement parsing,
  attestation verification), and tagged hash computation
- cdk-common: ConditionsDatabase trait, StoredCondition type,
  13xxx error codes, conditional MintKeySetInfo fields
- cdk-sql-common: SQLite/Postgres migrations and ConditionsDatabase
  implementation for conditions + conditional_keysets tables
- cdk-signatory: create_conditional_keyset with hash-derived
  derivation path
- cdk: mint logic for register_condition, get_conditions,
  process_redeem_outcome, and NUT-03 swap constraint to block
  conditional tokens in regular swaps
- cdk-axum: 5 HTTP endpoints (GET/POST /v1/conditions,
  GET /v1/conditions/{id}, GET /v1/conditional_keysets,
  POST /v1/redeem_outcome)
- NUT-06 mint info extension with nut28 settings field
- Witness::OracleWitness variant with custom serde
- 25 unit tests for core functions
@github-project-automation github-project-automation bot moved this to Backlog in CDK Feb 17, 2026
@ye0man ye0man moved this from Backlog to In progress in CDK Feb 17, 2026
…t condition_id, EC-based outcome_collection_id)

Aligns the CDK reference implementation with the spec changes from commit 63af400:

- condition_id is now partition-independent (partition_keys removed from hash)
- outcome_collection_id uses EC point operations (hash_to_curve + point addition)
  instead of simple tagged hash, absorbing the old NUT-29 collection_id concept
- Keyset ID derivation uses V2 with condition_id and outcome_collection_id
- API split: condition registration and partition registration are separate endpoints
  (POST /conditions and POST /conditions/{id}/partitions)
- Data model: collateral, parent_collection_id moved from condition to per-partition
- Conditional keysets now use KeySetVersion::Version01
- Add auth guards to all 6 conditional token endpoints
- Fix attestation race condition with WHERE attestation_status = 'pending'
- Add input size limits (announcements, partitions, descriptions)
- Fix panic on empty oracle_sigs with safe .first() access
- Verify all oracle signatures attest to the same outcome
- Reject empty outcome strings in partition validation
- Replace unwrap_or_default() with proper error propagation
- Validate output keyset existence and active status in redeem
- Add conditional-token errors to is_definitive_failure()
@joemphilips joemphilips changed the title feat: NUT-28 conditional tokens for prediction markets feat: NUT-CTF conditional tokens for prediction markets Feb 18, 2026
@joemphilips
Copy link
Author

joemphilips commented Feb 22, 2026

Superseded by new PR from renamed ctf branch (NUT-28/29/30 → NUT-CTF rename)
#1666

@github-project-automation github-project-automation bot moved this from In progress to Done in CDK Feb 22, 2026
@joemphilips joemphilips deleted the feat/ctf-28 branch February 22, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants