Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Improve symmetric encryption performance#542

Merged
matthewwalsh0 merged 3 commits intomainfrom
chore/improve-symmetric-encryption-performance
Feb 24, 2023
Merged

Improve symmetric encryption performance#542
matthewwalsh0 merged 3 commits intomainfrom
chore/improve-symmetric-encryption-performance

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented Feb 22, 2023

Overview

Improve the performance of the symmetric encryption by removing any hex encoding and instead transferring the encrypted data as byte arrays.

This will be most notable when decrypting many background messages in quick succession, especially large messages such as state messages with the sendUpdate method.

The cause of this issue was primarily the hex parsing algorithm in the Browserify Buffer.from polyfill. When receiving a background message, browser profiling showed that ~80% of the time spent was simply converting hex data to byte arrays.

A synthetic benchmark ran in the extension showed a reduction of 75% from ~1.4ms per iteration to ~0.35ms when decrypting a 5KB message 100,000 times.

Changes

Common

  • Remove all hex encoding and decoding.
  • Update related unit tests and mock data.

App

  • Update LavaMoat policies.

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review February 22, 2023 21:33
@matthewwalsh0 matthewwalsh0 requested a review from a team February 22, 2023 21:33
Copy link
Copy Markdown
Contributor

@cryptotavares cryptotavares left a comment

Choose a reason for hiding this comment

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

LGT! 🚀 ✅

@matthewwalsh0 matthewwalsh0 merged commit 55655de into main Feb 24, 2023
@matthewwalsh0 matthewwalsh0 deleted the chore/improve-symmetric-encryption-performance branch February 24, 2023 14:42
@cryptotavares cryptotavares mentioned this pull request Mar 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants