feat: NUT-CTF conditional tokens for prediction markets#1648
Closed
joemphilips wants to merge 3 commits intocashubtc:mainfrom
Closed
feat: NUT-CTF conditional tokens for prediction markets#1648joemphilips wants to merge 3 commits intocashubtc:mainfrom
joemphilips wants to merge 3 commits intocashubtc:mainfrom
Conversation
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
…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()
Author
|
Superseded by new PR from renamed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.