Skip to content

Commit 975c125

Browse files
Copilotwilliamdemeo
andcommitted
Add batch-level coin mint constraint to prevent Ada forgery (#1023)
* improvements * Initial plan * Add batchMintedCoin constraint to prevent Ada forgery Co-authored-by: williamdemeo <[email protected]> * Add documentation for batchMintedCoin security constraint Co-authored-by: williamdemeo <[email protected]> * Use consistent aggregation syntax for batchMintedCoin Co-authored-by: williamdemeo <[email protected]> --------- Co-authored-by: William DeMeo <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: williamdemeo <[email protected]>
1 parent 33678a8 commit 975c125

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Ledger/Dijkstra/Specification/Transaction.lagda.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,18 +422,6 @@ could be either of them.
422422
HasReferenceInputs-Tx : HasReferenceInputs (Tx txLevel)
423423
HasReferenceInputs-Tx .ReferenceInputsOf = ReferenceInputsOf ∘ TxBodyOf
424424
425-
HasSpendInputs-TxBody : HasSpendInputs (TxBody txLevel)
426-
HasSpendInputs-TxBody .SpendInputsOf = TxBody.txIns
427-
428-
HasSpendInputs-Tx : HasSpendInputs (Tx txLevel)
429-
HasSpendInputs-Tx .SpendInputsOf = SpendInputsOf ∘ TxBodyOf
430-
431-
HasReferenceInputs-TxBody : HasReferenceInputs (TxBody txLevel)
432-
HasReferenceInputs-TxBody .ReferenceInputsOf = TxBody.refInputs
433-
434-
HasReferenceInputs-Tx : HasReferenceInputs (Tx txLevel)
435-
HasReferenceInputs-Tx .ReferenceInputsOf = ReferenceInputsOf ∘ TxBodyOf
436-
437425
HasIndexedOutputs-TxBody : HasIndexedOutputs (TxBody txLevel)
438426
HasIndexedOutputs-TxBody .IndexedOutputsOf = TxBody.txOuts
439427

src/Ledger/Dijkstra/Specification/Utxo.lagda.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ module _ (Γ : UTxOEnv) (s : UTxOState) where
346346
batchPOV : Type
347347
batchPOV = batchConsumed ≡ batchProduced
348348
349+
-- Total Ada minted across the entire batch (top-level tx + all sub-txs).
350+
-- This must equal 0 to prevent Ada forgery and maintain the total Ada supply invariant.
351+
-- Analogous to Conway's `coin mint ≡ 0` constraint, but generalized to batches.
352+
batchMintedCoin : Coin
353+
batchMintedCoin = coin (MintedValueOf txTop) + sum (map (λ txSub → coin (MintedValueOf txSub)) (SubTransactionsOf txTop))
354+
349355
350356
351357
module Batch (Γ : UTxOEnv) (s : UTxOState) (txTop : TopLevelTx) where
@@ -398,13 +404,18 @@ module Batch (Γ : UTxOEnv) (s : UTxOState) (txTop : TopLevelTx) where
398404

399405
## The <span class="AgdaDatatype">UTXOS</span> Rule
400406

407+
408+
<!--
401409
```agda
402410
private variable
403411
Γ : UTxOEnv
404412
s s' : UTxOState
405413
tx : TopLevelTx
406414
stx : SubLevelTx
415+
```
416+
-->
407417

418+
```agda
408419
data _⊢_⇀⦇_,UTXOS⦈_ : UTxOEnv → UTxOState → TopLevelTx → UTxOState → Type where
409420
410421
UTXO-scripts✓ :
@@ -414,6 +425,7 @@ data _⊢_⇀⦇_,UTXOS⦈_ : UTxOEnv → UTxOState → TopLevelTx → UTxOState
414425
∙ Tx.isValid tx ≡ batchScripts✓ Γ s tx
415426
∙ batchScripts✓ Γ s tx ≡ true
416427
∙ batchPOV Γ s tx
428+
∙ batchMintedCoin Γ s tx ≡ 0
417429
────────────────────────────────
418430
Γ ⊢ s ⇀⦇ tx ,UTXOS⦈ s'-scripts✓
419431

0 commit comments

Comments
 (0)