Skip to content

Commit deda980

Browse files
committed
Use relative KES periods for evolution and signing
Previously KES keys would be evolved to the _current_ KES period, and would sign at that period. But this is incorrect; we should be caring about the number of evolutions since the first period, defined by the operational certificate. As such, we now sign with the _relative_ KES period (e.g. the number of evolutions), and evolve the keys accordingly.
1 parent e5caa3f commit deda980

File tree

1 file changed

+6
-3
lines changed
  • ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley

1 file changed

+6
-3
lines changed

ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Protocol.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ forgeTPraosFields :: ( MonadRandom m
162162
-> (TPraosToSign c -> toSign)
163163
-> m (TPraosFields c toSign)
164164
forgeTPraosFields updateNodeState TPraosProof{..} kesPeriod mkToSign = do
165-
hotKESKey <- evolveKESKeyIfNecessary updateNodeState kesPeriod
165+
hotKESKey <- evolveKESKeyIfNecessary updateNodeState (SL.KESPeriod kesEvolution)
166166
let
167167
signature = signedKES
168168
()
169-
kesPeriodNat
169+
kesEvolution
170170
(mkToSign signedFields)
171171
hotKESKey
172172
return TPraosFields {
@@ -175,6 +175,9 @@ forgeTPraosFields updateNodeState TPraosProof{..} kesPeriod mkToSign = do
175175
}
176176
where
177177
SL.KESPeriod kesPeriodNat = kesPeriod
178+
SL.OCert _ _ (SL.KESPeriod c0) _ = tpraosIsCoreNodeOpCert
179+
180+
kesEvolution = if kesPeriodNat >= c0 then kesPeriodNat - c0 else 0
178181

179182
TPraosIsCoreNode{..} = tpraosIsCoreNode
180183

@@ -193,7 +196,7 @@ forgeTPraosFields updateNodeState TPraosProof{..} kesPeriod mkToSign = do
193196
evolveKESKeyIfNecessary
194197
:: forall m c. (MonadRandom m, TPraosCrypto c)
195198
=> NodeState.Update m (TPraosNodeState c)
196-
-> SL.KESPeriod
199+
-> SL.KESPeriod -- ^ Relative KES period (to the start period of the OCert)
197200
-> m (SignKeyKES (KES c))
198201
evolveKESKeyIfNecessary updateNodeState (SL.KESPeriod kesPeriod) = do
199202
getOudatedKeyOrCurrentKey >>= \case

0 commit comments

Comments
 (0)