-
Notifications
You must be signed in to change notification settings - Fork 86
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 cardano-api Key interface for Hydra keys #398
Conversation
4e5a9c7
to
a1883f7
Compare
Transactions CostsSizes and execution budgets for Hydra protocol transactions. Note that unlisted parameters are currently using
Cost of Init Transaction
Cost of Commit TransactionCurrently only one UTxO per commit allowed (this is about to change soon)
Cost of CollectCom Transaction
Cost of Close Transaction
Cost of Contest Transaction
Cost of Abort Transaction
Cost of FanOut TransactionInvolves spending head output and burning head tokens. Uses ada-only UTxO for better comparability.
|
4048: Expose Key interface in Cardano.Api.Shelley r=ch1bo a=ch1bo Sorry for this unsolicited PR, it is *not* crucial for us, but we wanted to get also your feedback on: In the Hydra project we are using the cardano-api quite heavily and thought we could distinguish Hydra key types using the same framework, but just with a new `Hydra` key role. Unfortunately it was not possible because some of the type class definition was not exported. This PR exposes the full type class to be able to define instances of it and having a `Hydra` key role, this yields `SigningKey Hydra` and `VerificationKey Hydra` key types. See also this PR: cardano-scaling/hydra#398 4137: Give myself and John permission to merge any PR r=Jimbo4350 a=Jimbo4350 Co-authored-by: Sebastian Nagel <[email protected]> Co-authored-by: Jordan Millar <[email protected]>
The upstream PR in cardano-node has been merged. We could be trying to use 0cd6878769a10097e7c780e15efb9919fb94f669, but likely only after #408 has been merged. |
a1883f7
to
e413f47
Compare
Fast-forwarded this one, but will fail tests as cardano-node HEAD is still missing IntersectMBO/cardano-node#4138. |
df515ba
to
e7fb2a5
Compare
628156e
to
ea7a26b
Compare
Update: The required changes are now on |
ea7a26b
to
8d572f4
Compare
hydra-node/src/Hydra/Crypto.hs
Outdated
-- | The used hash algorithm for 'HydraKey' verification key hashes. | ||
type HashAlg = Blake2b_256 | ||
|
||
-- | The used signature algorithm for 'HydraKey' signatures. | ||
type SignAlg = Ed25519DSIGN |
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.
(strong 😅) suggestion: do not use type-aliases here.
This obfuscates things, and provide little benefits. It's replacing one word by another. I would imagine having a type-class that spits back the algorithm from a given Key HydraKey
for example if consistency is needed, but the alias makes signatures more opaque.
Plus, this is relatively inconsistent with the rest of the Cardano codebase, which does not use type-aliases for these but rather (a) generic type parameters (.e.g alg
-- lowercase) or (b) specialized types like Key PaymentKey
where the hash algorithm is fixed anyway behind the scene.
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.
Yeah, makes sense. I was following the pattern we also used in other modules where we fixed the Era
or Block
types etc. I will follow your suggestion and remove this one indirection 👍
where | ||
needed = fromIntegral $ seedSizeDSIGN (Proxy :: Proxy SignAlg) | ||
provided = BS.length seed | ||
padded = seed <> BS.pack (replicate (needed - provided) 0) |
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.
That is slightly odd 🤔 ...
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 already on master
:P But it's currently getting fixed by @ffakenz to not pad, but hash the seed for a consistent key derivation.
hashVerificationKey (HydraVerificationKey vk) = | ||
castHash $ hashVerKeyDSIGN vk | ||
-- | Create a new 'SigningKey' from a 'ByteString' seed. The created keys are | ||
-- not random and insecure, so don't use this in production code! |
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.
Can we mark it as {-# DEPRECATED #-}
? I think this would prevent us from compiling test code with -WError but .. I see some obvious benefits. This is also enforceable by hlint I think (where we can whitelist some modules where a particular function is allowed) but that supposes we do all run and obey to hlint.
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.
It would probably trip the call site above in deterministicSigningKey
(iirc)
@@ -69,14 +67,18 @@ initEnvironment Options{hydraSigningKey, hydraVerificationKeys} = do | |||
, otherParties | |||
} | |||
where | |||
-- TODO: use text envelopes instead of this maybe fail stuff |
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.
👍
@@ -18,8 +18,8 @@ let | |||
cardano-node = import | |||
(pkgs.fetchgit { | |||
url = "https://github.com/input-output-hk/cardano-node"; | |||
rev = "1.35.0"; | |||
sha256 = "06arx9hv7dn3qxfy83f0b6018rxbsvh841nvfyg5w6qclm1hddj7"; | |||
rev = "1.35.3-testnetonly"; |
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 does this even exist.
This is makes key representation more uniform between Cardano and Hydra credentials, yet distinct.
This commit holds both of our upstream contributions: * The Key data family exposed * A fixed orphan instance of ToJSON Script We also needed to update the dependencies on cardano-base, cardano-ledger and ouroboros-network. Note that these source dependencies are further ahead on master than the binary cardano-node we use.
Also bump hydra-cluster package version as it seems to not have been updated
This was introduced with babbage (CIP-55) and the cardano-api is (now?) pedantic about this (errors if it is missing).
e3b9839
to
3b68e69
Compare
4048: Expose Key interface in Cardano.Api.Shelley r=ch1bo a=ch1bo Sorry for this unsolicited PR, it is *not* crucial for us, but we wanted to get also your feedback on: In the Hydra project we are using the cardano-api quite heavily and thought we could distinguish Hydra key types using the same framework, but just with a new `Hydra` key role. Unfortunately it was not possible because some of the type class definition was not exported. This PR exposes the full type class to be able to define instances of it and having a `Hydra` key role, this yields `SigningKey Hydra` and `VerificationKey Hydra` key types. See also this PR: cardano-scaling/hydra#398 4137: Give myself and John permission to merge any PR r=Jimbo4350 a=Jimbo4350 Co-authored-by: Sebastian Nagel <[email protected]> Co-authored-by: Jordan Millar <[email protected]>
4048: Expose Key interface in Cardano.Api.Shelley r=ch1bo a=ch1bo Sorry for this unsolicited PR, it is *not* crucial for us, but we wanted to get also your feedback on: In the Hydra project we are using the cardano-api quite heavily and thought we could distinguish Hydra key types using the same framework, but just with a new `Hydra` key role. Unfortunately it was not possible because some of the type class definition was not exported. This PR exposes the full type class to be able to define instances of it and having a `Hydra` key role, this yields `SigningKey Hydra` and `VerificationKey Hydra` key types. See also this PR: cardano-scaling/hydra#398 4137: Give myself and John permission to merge any PR r=Jimbo4350 a=Jimbo4350 Co-authored-by: Sebastian Nagel <[email protected]> Co-authored-by: Jordan Millar <[email protected]>
This PR rolls up the previous custom types into
cardano-api
Key
interface and yieldsSigningKey Hydra
andVerificationKey Hydra
key types.Requires a patch upstream to have the
Key
type class fully exposed.See this PR: IntersectMBO/cardano-node#4048