-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use mlocked KES internally #1374
base: main
Are you sure you want to change the base?
Conversation
d7d3c8f
to
3c994f0
Compare
3c994f0
to
cfddb02
Compare
@@ -143,6 +143,9 @@ data BlockForging m blk = BlockForging { | |||
-> [Validated (GenTx blk)] -- Transactions to include | |||
-> IsLeader (BlockProtocol blk) -- Proof we are leader | |||
-> m blk | |||
|
|||
, finalize :: m () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this "finalizing"? (please add some haddocks here too)
@@ -108,6 +109,10 @@ data family CodecConfig blk :: Type | |||
-- avoid circular dependencies. | |||
data family StorageConfig blk :: Type | |||
|
|||
-- | Credentials needed for block forging. In eras that use KES, this will be | |||
-- a pair of KES sign key and OpCert; in other eras, it should be 'Void'. | |||
type family BlockForgingCredentials blk :: Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is defined here, and for the HFBlock, but nowhere else?
@@ -77,6 +77,8 @@ deriving stock instance CanHardFork xs => Show (LedgerState (HardForkBlock xs) | |||
deriving stock instance CanHardFork xs => Eq (LedgerState (HardForkBlock xs)) | |||
deriving newtype instance CanHardFork xs => NoThunks (LedgerState (HardForkBlock xs)) | |||
|
|||
type instance BlockForgingCredentials (HardForkBlock '[blk]) = BlockForgingCredentials blk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
@@ -11,6 +11,7 @@ | |||
{-# LANGUAGE RecordWildCards #-} | |||
{-# LANGUAGE ScopedTypeVariables #-} | |||
{-# LANGUAGE TypeApplications #-} | |||
{-# LANGUAGE TypeFamilies #-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary?
hardForkFinalize :: (Monad m, All Top xs) | ||
=> NonEmptyOptNP (BlockForging m) xs -> m () | ||
hardForkFinalize blockForging = | ||
-- pure () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
@@ -475,12 +476,12 @@ protocolInfoCardano paramsCardano | |||
, length credssShelleyBased > 1 | |||
= error "Multiple Shelley-based credentials not allowed for mainnet" | |||
| otherwise | |||
= assertWithMsg (validateGenesis genesisShelley) | |||
= assertWithMsg (validateGenesis genesisShelley) $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= assertWithMsg (validateGenesis genesisShelley) $ | |
= assertWithMsg (validateGenesis genesisShelley) |
, ProtocolParamsByron | ||
, ProtocolParamsShelleyBased | ||
, CheckpointsMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these exported? They are not new to this PR
- Change `HotKey` to manage not only KES sign keys, but also the corresponding | ||
OpCerts. This is in preparation for KES agent connectivity: with the new | ||
design, the KES agent will provide both KES sign keys and matching OpCerts | ||
together, and we need to be able to dynamically replace them both together. | ||
- Add finalizer to `HotKey`. This takes care of securely forgetting any KES | ||
keys the HotKey may still hold, and will be called automatically when the | ||
owning block forging terminates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this done in the protocol package instead?
- The `KesKey` data type in `unstable-cardano-tools` has been renamed to | ||
`UnsoundPureKesKey`, to reflect the fact that it uses the old, unsound KES | ||
API (which does not use mlocking or secure forgetting). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't reflect these changes in the changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure we want to merge this as is. If we did so Consensus would be unreleasable until those other dependencies are released. I think we should wait until there are no more source-repository-package
stanzas.
This changes Consensus such that mlocked KES keys are used internally.
This is important groundwork for supporting KES agents in the future. In this form, the code will still load KES keys from disk, which is unsound, but the internal machinery is ready to also accept KES keys from other sources, and once loaded, KES keys will be handled appropriately (kept in mlocked RAM at all times, securely erased when expired).
This also involves a restructuring of the
HotKey
data structure, which now manages not only a KES SignKey, but also the corresponding OpCert. This is necessary for two reasons:Supersedes #1284.