Skip to content

Commit

Permalink
Added hash to VKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Soupstraw committed Nov 22, 2024
1 parent 7b9b73d commit 6cc0b86
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/Ledger/Conway/Foreign/HSLedger/Address.agda
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module Ledger.Conway.Foreign.HSLedger.Address where
open import Ledger.Conway.Foreign.HSLedger.BaseTypes

instance
HsTy-HSVKey = autoHsType HSVKey
Conv-HSVKey = autoConvert HSVKey

HsTy-Credential = autoHsType Credential
Conv-Credential = autoConvert Credential

Expand Down
22 changes: 18 additions & 4 deletions src/Ledger/Conway/Foreign/HSLedger/Core.agda
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ open import Ledger.Transaction renaming (Vote to VoteTag) public

open import Ledger.Conway.Foreign.Util public

open import Tactic.Derive.DecEq
open import Tactic.Derive.Show

module _ {A : Type} ⦃ _ : DecEq A ⦄ ⦃ _ : Show A ⦄ where instance
∀Hashable : Hashable A A
∀Hashable = λ where .hash id
Expand All @@ -33,6 +36,17 @@ instance
Hashable-⊤ : Hashable ⊤ ℕ
Hashable-⊤ = λ where .hash tt 0

record HSVKey : Type where
constructor MkHSVKey
field vkey :
storedHash :

unquoteDecl DecEq-HSVKey = derive-DecEq
((quote HSVKey , DecEq-HSVKey) ∷ [])

unquoteDecl Show-HSVKey = derive-Show
((quote HSVKey , Show-HSVKey) ∷ [])

module Implementation where
Network =
SlotsPerEpochᶜ = 100
Expand All @@ -41,11 +55,11 @@ module Implementation where
NetworkId = 0 -- Testnet

SKey =
VKey =
VKey = HSVKey
Sig =
Ser =

isKeyPair = _≡_
isKeyPair = λ sk vk sk ≡ HSVKey.vkey vk
sign = _+_
ScriptHash =

Expand Down Expand Up @@ -115,11 +129,11 @@ module ExternalStructures (externalFunctions : ExternalFunctions) where
HSPKKScheme : PKKScheme
HSPKKScheme = record
{ Implementation
; isSigned = λ a b m extIsSigned a b m ≡ true
; isSigned = λ a b m extIsSigned (HSVKey.vkey a) b m ≡ true
; sign = λ _ _ zero
-- we can't prove these properties since the functions are provided by the Haskell implementation
; isSigned-correct = error "isSigned-correct evaluated"
; Dec-isSigned = λ { {vk} {ser} {sig} ⁇ (extIsSigned vk ser sig because error "Dec-isSigned evaluated") }
; Dec-isSigned = λ { {vk} {ser} {sig} ⁇ (extIsSigned (HSVKey.vkey vk) ser sig because error "Dec-isSigned evaluated") }
}

-- No P2 scripts for now
Expand Down
3 changes: 2 additions & 1 deletion src/Ledger/Conway/Foreign/HSLedger/Utxo.agda
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ open import Foreign.Haskell.Coerce
open import Ledger.Conway.Foreign.HSLedger.BaseTypes hiding (TxWitnesses)
open import Ledger.Conway.Conformance.Utxo DummyTransactionStructure DummyAbstractFunctions
open import Ledger.Conway.Conformance.Utxow DummyTransactionStructure DummyAbstractFunctions
renaming (module L to LW)

instance
HsTy-UTxOEnv = autoHsType UTxOEnv ⊣ withConstructor "MkUTxOEnv"
Expand Down Expand Up @@ -77,7 +78,7 @@ module _ (ext : ExternalFunctions) where
open TxWitnesses (coerce ⦃ TrustMe ⦄ wits)
in unlines
$ "witsVKeyNeeded utxo txb = "
∷ show (witsVKeyNeeded utxo body)
∷ show (LW.witsVKeyNeeded utxo body)
"\nwitsKeyHashes = "
∷ show (mapˢ hash (dom vkSigs))
--∷ "\ncredsNeeded = "
Expand Down

0 comments on commit 6cc0b86

Please sign in to comment.