@@ -3,12 +3,7 @@ source_branch: master
33source_path : src/Ledger/Dijkstra/Specification/Utxow.lagda.md
44---
55
6- # UTxOW (Dijkstra skeleton)
7-
8- This is a ** minimal skeleton** of the Dijkstra-era witnessing layer.
9-
10- It currently acts as a wrapper around ` UTXO ` , mirroring Conway's shape, but without
11- committing to full witnessing checks yet.
6+ # UTxOW
127
138<!--
149```agda
@@ -24,30 +19,133 @@ module Ledger.Dijkstra.Specification.Utxow
2419 where
2520
2621open import Ledger.Dijkstra.Specification.Utxo txs abs
22+ open import Ledger.Dijkstra.Specification.Script.Validation txs abs
2723
2824private variable
25+ ℓ : TxLevel
2926 Γ : UTxOEnv
3027 s s' : UTxOState
3128 tx : TopLevelTx
3229 stx : SubLevelTx
3330```
3431-->
3532
33+ ``` agda
34+ languages : Tx ℓ → UTxO → ℙ Language
35+ languages tx utxo = ∅ -- TODO
36+
37+ allowedLanguages : Tx ℓ → UTxO → ℙ Language
38+ allowedLanguages tx utxo = ∅ -- TODO
39+ ```
40+
3641``` agda
3742data _⊢_⇀⦇_,SUBUTXOW⦈_ : UTxOEnv → UTxOState → SubLevelTx → UTxOState → Type where
3843
3944 SUBUTXOW :
45+ let
46+ open Tx tx
47+ open TxBody txBody
48+ open TxWitnesses txWitnesses
49+ open UTxOEnv
50+
51+ utxo₀ = Γ .utxo₀
52+ utxo = s .UTxOState.utxo
53+
54+ witsKeyHashes : ℙ KeyHash
55+ witsKeyHashes = mapˢ hash (dom vKeySigs)
56+
57+ allScripts : ℙ Script
58+ allScripts =
59+ ( scripts -- (1) scripts from witnesses
60+ ∪ mapPartial txOutToScript
61+ ( range (utxo₀ ∣ txIns) -- (2) scripts from transaction inputs
62+ ∪ range (utxo ∣ refInputs) -- (3) scripts from reference inputs
63+ )
64+ ∪ Γ .globalRefInputsScripts -- (4) scripts from global reference inputs
65+ )
66+
67+ p1Scripts : ℙ P1Script
68+ p1Scripts = mapPartial toP1Script allScripts
69+
70+ p2Scripts : ℙ P2Script
71+ p2Scripts = mapPartial toP2Script allScripts
72+
73+ neededScriptHashes : ℙ ScriptHash
74+ neededScriptHashes = mapPartial (isScriptObj ∘ proj₂) (credsNeeded utxo₀ txBody)
75+
76+ neededVKeyHashes : ℙ KeyHash
77+ neededVKeyHashes = mapPartial (isKeyHashObj ∘ proj₂) (credsNeeded utxo₀ txBody)
78+
79+ neededDataHashes : ℙ DataHash
80+ neededDataHashes = mapPartial (λ txOut@(a , _ , d , _) → do sh ← isScriptObj (payCred a)
81+ _ ← lookupHash sh p2Scripts
82+ d >>= isInj₂)
83+ (range (utxo₀ ∣ txIns))
84+
85+ in
86+ ∙ ∀[ (vk , σ) ∈ vKeySigs ] isSigned vk (txidBytes txId) σ
87+ ∙ ∀[ s ∈ p1Scripts ] (hash s ∈ neededScriptHashes → validP1Script witsKeyHashes txVldt s)
88+ ∙ neededVKeyHashes ⊆ witsKeyHashes
89+ ∙ neededScriptHashes ⊆ mapˢ hash allScripts
90+ ∙ neededDataHashes ⊆ dom (Γ .globalData)
91+ ∙ languages tx utxo ⊆ allowedLanguages tx utxo
92+ ∙ txADhash ≡ map hash txAuxData
4093 ∙ Γ ⊢ s ⇀⦇ stx ,SUBUTXO⦈ s'
4194 ────────────────────────────────
4295 Γ ⊢ s ⇀⦇ stx ,SUBUTXOW⦈ s'
4396
4497data _⊢_⇀⦇_,UTXOW⦈_ : UTxOEnv → UTxOState → TopLevelTx → UTxOState → Type where
4598
4699 UTXOW :
47- ∙ Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s'
100+ let
101+ open Tx tx
102+ open TxBody txBody
103+ open TxWitnesses txWitnesses
104+ open UTxOEnv
105+
106+ utxo₀ = Γ .utxo₀
107+ utxo = s .UTxOState.utxo
108+
109+ witsKeyHashes : ℙ KeyHash
110+ witsKeyHashes = mapˢ hash (dom vKeySigs)
111+
112+ allScripts : ℙ Script
113+ allScripts =
114+ ( scripts -- (1) scripts from witnesses
115+ ∪ mapPartial txOutToScript
116+ ( range (utxo₀ ∣ txIns) -- (2) scripts from transaction inputs
117+ ∪ range (utxo ∣ refInputs) -- (3) scripts from reference inputs
118+ )
119+ ∪ Γ .globalRefInputsScripts -- (4) scripts from global reference inputs
120+ )
121+
122+ p1Scripts : ℙ P1Script
123+ p1Scripts = mapPartial toP1Script allScripts
124+
125+ p2Scripts : ℙ P2Script
126+ p2Scripts = mapPartial toP2Script allScripts
127+
128+ neededScriptHashes : ℙ ScriptHash
129+ neededScriptHashes = mapPartial (isScriptObj ∘ proj₂) (credsNeeded utxo₀ txBody)
130+
131+ neededVKeyHashes : ℙ KeyHash
132+ neededVKeyHashes = mapPartial (isKeyHashObj ∘ proj₂) (credsNeeded utxo₀ txBody)
133+
134+ neededDataHashes : ℙ DataHash
135+ neededDataHashes = mapPartial (λ txOut@(a , _ , d , _) → do sh ← isScriptObj (payCred a)
136+ _ ← lookupHash sh p2Scripts
137+ d >>= isInj₂)
138+ (range (utxo₀ ∣ txIns))
139+
140+ in
141+ ∙ ∀[ (vk , σ) ∈ vKeySigs ] isSigned vk (txidBytes txId) σ
142+ ∙ ∀[ s ∈ p1Scripts ] (hash s ∈ neededScriptHashes → validP1Script witsKeyHashes txVldt s)
143+ ∙ neededVKeyHashes ⊆ witsKeyHashes
144+ ∙ neededScriptHashes ⊆ mapˢ hash allScripts
145+ ∙ neededDataHashes ⊆ dom (Γ .globalData)
146+ ∙ languages tx utxo ⊆ allowedLanguages tx utxo
147+ ∙ txADhash ≡ map hash txAuxData
148+ ∙ Γ ⊢ s ⇀⦇ tx ,UTXO⦈ s'
48149 ────────────────────────────────
49150 Γ ⊢ s ⇀⦇ tx ,UTXOW⦈ s'
50151```
51-
52- This file intentionally contains ** no** additional premises yet. As Dijkstra witnessing
53- evolves, this is where signature / script / datum / language constraints can be added.
0 commit comments