Add compression to encrypted data URL param#16
Merged
Conversation
54513ff to
88f5b8b
Compare
vishnumad
commented
Oct 23, 2024
| "test": "jest", | ||
| "test:coverage": "yarn test:unit && open coverage/lcov-report/index.html", | ||
| "prebuild": "rm -rf ./build && node -p \"'export const LIB_VERSION = \\'' + require('./package.json').version + '\\';'\" > src/version.ts", | ||
| "prebuild": "rm -rf ./dist && node -p \"'export const LIB_VERSION = \\'' + require('./package.json').version + '\\';'\" > src/version.ts", |
Collaborator
Author
There was a problem hiding this comment.
./build doesn't exist
cb-jake
reviewed
Oct 25, 2024
| encrypted: { | ||
| iv: hexToBytes(iv), | ||
| cipherText: hexToBytes(cipherText), | ||
| iv: new Uint8Array(Buffer.from(iv, 'base64')), |
Collaborator
There was a problem hiding this comment.
Does noble hashes not have a util for this?
Collaborator
Author
There was a problem hiding this comment.
Doesn't look like it
cb-jake
approved these changes
Oct 25, 2024
Collaborator
cb-jake
left a comment
There was a problem hiding this comment.
Changes make sense. Tested against pending sw release. Probably worth a second review as I ramp up on this codebase
This reverts commit 88f5b8b.
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.
Summary
Base64:
Currently we encode our encrypted cipher text as a hex string to send to Smart Wallet frontend. However hex encoding doubles the length of the cipher text. So 1000 bytes of encrypted cipher text becomes 2000 chars. We can use base64 encoding for improved space efficiency. 1000 bytes of encrypted cipher text becomes 1336 chars. This becomes a significant savings for large requests.
Zlib compression:
This PR also adds support for zlib compressing the request data with
fflatebefore it's encrypted. For the example large transaction, this reduces URL length to 1990 chars. Based off #17I opted to leave the URL param encoding logic as is, since using a different format like msgpack seems to only have small gains (< 50 chars) and requires introducing another dependency.
Small Request
Hex: 834 chars
Zlib+Base64: 732 chars
Large Request
Hex: 9310 chars
Zlib+Base64: 1990 chars
How did you test your changes?
Tested manually + unit tests