Skip to content
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

feat(crypto-js): Implement the Attachment API #958

Merged
merged 2 commits into from Aug 17, 2022

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Aug 16, 2022

Implement the Attachment.encrypt and Attachment.decrypt methods,
along with its EncryptedAttachment companion.

The trick is to avoid copies as much as possible. Instead of dealing
with Uint8Array as I've initially done, &[u8] and Vec<u8> is
passed instead. wasm-bindgen is smart enough to do as few copies as
possible (from JavaScript to Wasm's memory is required, and we don't
want to do more), while typing everything as Uint8Array.

EncryptedAttachment.encryptedData returns a copy of the data
everytime it is called, and that's the last copy I'm not happy with.

Implement the `Attachment.encrypt` and `Attachment.decrypt` methods,
along with its `EncryptedAttachment` companion.

The trick is to avoid copies as much as possible. Instead of dealing
with `Uint8Array` as I've initially done, `&[u8]` and `Vec<u8>` is
passed instead. `wasm-bindgen` is smart enough to do as few copies as
possible (from JavaScript to Wasm's memory is required, and we don't
want to do more), while typing everything as `Uint8Array`.

`EncryptedAttachment.encryptedData` returns a copy of the data
everytime it is called, and that's the last copy I'm not happy with.
@Hywan Hywan added enhancement New feature or request bindings labels Aug 16, 2022
@Hywan Hywan requested review from turt2live and a team August 16, 2022 14:14
@codecov
Copy link

codecov bot commented Aug 16, 2022

Codecov Report

Merging #958 (45a66f3) into main (fd220f1) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #958   +/-   ##
=======================================
  Coverage   80.33%   80.33%           
=======================================
  Files         110      110           
  Lines       15806    15806           
=======================================
  Hits        12698    12698           
  Misses       3108     3108           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@gnunicorn gnunicorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine to me

@Hywan Hywan changed the title feat(crypto-js): Implemented the Attachment API feat(crypto-js): Implement the Attachment API Aug 17, 2022
@Hywan Hywan merged commit a1dca23 into matrix-org:main Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants