Skip to content

Commit

Permalink
Merge pull request #4790 from IntersectMBO/nm/VRFVerKeyHash-conversion
Browse files Browse the repository at this point in the history
Add functions to convert hashes to and from `VRFVerKeyHash`
  • Loading branch information
lehins authored Dec 9, 2024
2 parents f8b21d7 + 3fe0221 commit 12f6aa6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

1 comment on commit 12f6aa6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Haskell Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 12f6aa6 Previous: f8b21d7 Ratio
applyTxBenchmarks/ApplyTxInEra/ShelleyEra C_Crypto 0.00010634011069255462 Nanoseconds (0.000012309261405252147) 0.0000530014070689778 Nanoseconds (0.0000015074312661796877) 2.01
applyTxBenchmarks/ApplyTxInEra/AllegraEra C_Crypto 0.00012384871900949235 Nanoseconds (0.000023489396844338862) 0.00005942890815172612 Nanoseconds (4.2158031390575315e-7) 2.08
applyTxBenchmarks/Deserialise Shelley Tx/ShelleyEra C_Crypto 0.000019079327322378032 Nanoseconds (4.0479865739052705e-7) 0.000009454323546064946 Nanoseconds (1.0896962525982816e-7) 2.02
applyTxBenchmarks/Deserialise Shelley Tx/AllegraEra C_Crypto 0.000036544164365240576 Nanoseconds (0.000003716453696291504) 0.000017692204057757273 Nanoseconds (4.893017821818914e-7) 2.07
applyTxBenchmarks/Deserialise Shelley Tx/MaryEra C_Crypto 0.00003779967084136116 Nanoseconds (0.000003915412326624652) 0.00001790997362460671 Nanoseconds (7.743818738677526e-7) 2.11
applyTxBenchmarks/Deserialise Shelley Tx/AlonzoEra C_Crypto 0.00001973118159094004 Nanoseconds (9.260602634513965e-7) 0.000009755187765841384 Nanoseconds (6.642577606437604e-7) 2.02

This comment was automatically generated by workflow using github-action-benchmark.

CC: @nc6

Please sign in to comment.