[FS-721] Forward All Default Proposals#2628
Conversation
c7b25b7 to
3d3265e
Compare
aed3c11 to
734c569
Compare
- This was introduced accidentally
| let sig = BA.convert $ sign priv pub (rmRaw tbs) | ||
| pure (Message tbs (MessageExtraFields sig Nothing Nothing)) | ||
|
|
||
| mkAppAckProposalMessage :: |
There was a problem hiding this comment.
This isn't used, is it?
| mkAppAckProposalMessage priv pub gid epoch ref mrs = | ||
| maybeCryptoError $ mkAppAckProposalMessageFailable priv pub gid epoch ref mrs | ||
|
|
||
| mkAppAckProposalMessageFailable :: |
There was a problem hiding this comment.
This is only used for testing, couldn't it just be moved to the tests?
There was a problem hiding this comment.
Maybe this function and mkRemoveProposalMessage can be factored to use a common function that signs a MessageTBS to (Message 'MLSPlainText)?
Also I noted that both functions use maybeCryptoError together with a pure which is just CryptoPassed. I think because of that in both functions nothing is acutally checked. Can we remove this indirection?
There was a problem hiding this comment.
Yes, only in testing. I simplified and moved it to the test code in 39d7c31.
| [a] -> | ||
| Put | ||
| serialiseMLSVector p as = do | ||
| put @w . fromIntegral . length $ as |
There was a problem hiding this comment.
This is not correct. Vectors begin with the whole size of their binary representation, not the number of items. See https://www.rfc-editor.org/rfc/rfc5246#section-4.3.
| ) | ||
| @?= [Ed25519] | ||
|
|
||
| propUnsupported :: TestM () |
There was a problem hiding this comment.
This is a somewhat unconventional test. Maybe add a couple of lines of comment explaining what it is we're doing here, like the fact that we are manually reading mls-test-cli's store and extracting the private key.
pcapriotti
left a comment
There was a problem hiding this comment.
Looks good except for the vector serialisation. See comment below.
| let elLen = maybe 0 (LBS.length . runPut . p) . listToMaybe $ as | ||
| put @w . fromIntegral $ elLen * fromIntegral (length as) | ||
| traverse_ p as |
There was a problem hiding this comment.
This doesn't look right to me. Why is every element the same length?
To be fair, it's not easy to do this efficiently. As a compromise, we can do the following:
- serialise the whole vector ignoring the size
- convert to lazy bytestring
- put count
- put bytestring
To get good performance we need imperative access to the buffer, which is probably possible, but requires the unsafe API. Maybe the above is good enough.
There was a problem hiding this comment.
Good points! I obviously overlooked this.
I changed the implementation and round-trip tests for serialiseMLSVector pass. I am not too familiar with how efficient the conversion from a lazy bytestring to a strict bytestring is, but that's what I did.
There was a problem hiding this comment.
Lazy bytestrings are essentially lists of strict bytestrings (representing their concatenation). Converting from lazy to strict amounts to actually performing the concatenation (i.e. basically allocating a big buffer, copying, and likely leaving the original bytestrings to the GC). So it's basically a bunch of extra copies and allocations, good to avoid if possible.
- This change makes the round-trip test for the serialiseMLSVector pass (via the ExtensionVector test type)
| serialiseMLSBytes @w . LBS.toStrict . toLazyByteString | ||
| . execPut | ||
| . traverse_ p |
There was a problem hiding this comment.
This looks correct, but we can avoid the bytestring conversion if we create a version of serialiseMLSBytes that takes a lazy bytestring and uses putLazyByteString.
There was a problem hiding this comment.
Thanks again! I've implemented that in 8ce0da0.
The PR adapts the Wire server such that it simply forwards all MLS default proposal types, including those that it currently does not support.
Tracked by https://wearezeta.atlassian.net/browse/FS-721.
Checklist
changelog.d.