Consistently use message buffer type aliases#365
Merged
geonnave merged 3 commits intolake-rs:mainfrom Jun 2, 2025
Merged
Conversation
This reduces the amount of necessary copying, and decouples the functions from predefined lengths (given that they were originally designed for a concrete type, then used with other types, which only works while those are aliased). The length generic being decoupled from the input length does raise a few new cases of panicking (maybe even unsoundness, in the cryptocell case), but at least for encrypting (where more data is written to the output than in the input), those were already present before, and are better tackled independently from the refactoring. Contributes-To: lake-rs#363
The new types are all aliases of the old, but those now work even when of all the type aliases of EdhocMessageBuffer in shared/src/lib.rs, new explicitly different sizes are chosen. (Except for EdhocCiphertext2 and EdhocPlaintext2 which need to be the same size lest their encrypt_decrypt function needs duplication).
Merged
geonnave
reviewed
May 27, 2025
| pub x: BytesP256ElemLen, | ||
| pub g_y: BytesP256ElemLen, | ||
| pub plaintext_2: EdhocMessageBuffer, | ||
| pub plaintext_2: BufferPlaintext2, |
Collaborator
There was a problem hiding this comment.
Is there a reason why some places are plaintext: &[u8] and others are plaintext_2: BufferPlaintext2 ?
Member
Author
There was a problem hiding this comment.
I didn't revisit yet where we can get rid of buffers and uses slices instead; that's a follow-up step.
Collaborator
|
Went through and LGTM. 👍 when you think it's ready? |
Member
Author
|
I think this is ready. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This cleans up some of #363.
I think those are sensible enhancements at this point. They are crucial for making perfect use of the #362 typestate buffers (because to make maximum use of that, we'll need to size the buffers so that the right ones fit in each other, and we can thus tell at build time that some operations can't overflow) -- but even without that, I'd like to build on them to reduce type confusion.