-
Notifications
You must be signed in to change notification settings - Fork 156
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 signable representations #1666
Conversation
We use this in place of the tuple previously. We now have full control of how this is serialised for signing.
To construct the SignableRepresentation for OCertSignable, rather than manually appending bytestrings created in different ways.
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.
looks good generally, just the OCert that's a bit squiffy
<> BSL.toStrict (Binary.encode counter) | ||
<> writeBinaryWord64 (fromIntegral $ unKESPeriod period) |
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.
These two should both be at-most 64bit numbers, so we should serialise them the same.
tbh, we should probably use Word64 for the cert counter not natural.
@dcoutts I agree that the counter should probably be bounded, but on the basis that it's not, I'm wary of serialising it as if it is, since that allows a potential attack. Since we compare the counter, one could replay the ocert counter |
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.
LGTM.
We should add a TODO to use a newtype wrapper for the cert counter.
BSL.toStrict . Binary.runPut $ do | ||
Binary.putByteString (KES.rawSerialiseVerKeyKES vk) | ||
Binary.put counter | ||
Binary.putWord64be (fromIntegral $ unKESPeriod period) |
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.
The bytestring builder will be faster
BSL.toStrict . Binary.runPut $ do | |
Binary.putByteString (KES.rawSerialiseVerKeyKES vk) | |
Binary.put counter | |
Binary.putWord64be (fromIntegral $ unKESPeriod period) | |
runByteBuilder (32+8+8) $ do | |
BS.byteStringCopy (KES.rawSerialiseVerKeyKES vk) | |
BS.word64BE counter | |
BS.word64BE (fromIntegral $ unKESPeriod period) |
Needs
import Shelley.Spec.Ledger.Serialization (runByteBuilder)
import qualified Data.ByteString.Builder as BS
import qualified Data.ByteString.Builder.Extra as BS
No description provided.