Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to convert hashes to and from VRFVerKeyHash #4790

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/cardano-ledger-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.16.0.0

* Add `toVRFVerKeyHash` and `fromVRFVerKeyHash`
* Change lens type of `hkdNOptL`, `ppNOptL`, and `ppuNOptL` to `Word16`
* Add `epochFromSlot`
* Remove usage of a `Reader` monad in `epochInfoEpoch`, `epochInfoFirst` and `epochInfoSize`.
Expand Down
12 changes: 11 additions & 1 deletion libs/cardano-ledger-core/src/Cardano/Ledger/Keys/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ module Cardano.Ledger.Keys.Internal (
KeyRoleVRF (..),
VRFVerKeyHash (..),
hashVerKeyVRF,
toVRFVerKeyHash,
fromVRFVerKeyHash,

-- * Genesis delegations
GenDelegPair (..),
Expand Down Expand Up @@ -373,4 +375,12 @@ deriving newtype instance Crypto c => Default (VRFVerKeyHash r c)

hashVerKeyVRF ::
Crypto c => VerKeyVRF c -> VRFVerKeyHash (r :: KeyRoleVRF) c
hashVerKeyVRF = VRFVerKeyHash . Hash.castHash . VRF.hashVerKeyVRF
hashVerKeyVRF = toVRFVerKeyHash . VRF.hashVerKeyVRF

toVRFVerKeyHash ::
Hash.Hash (HASH c) (VRF.VerKeyVRF v) -> VRFVerKeyHash (r :: KeyRoleVRF) c
toVRFVerKeyHash = VRFVerKeyHash . Hash.castHash

fromVRFVerKeyHash ::
VRFVerKeyHash (r :: KeyRoleVRF) c -> Hash.Hash (HASH c) (VRF.VerKeyVRF v)
fromVRFVerKeyHash = Hash.castHash . unVRFVerKeyHash
Loading