staticrypt icon indicating copy to clipboard operation
staticrypt copied to clipboard

Compress encrypted data

Open jimhark opened this issue 5 months ago • 2 comments

Summary

Compress data before encryption because it reduces size by about 30%, at a minimal additional compute cost compared to encryption and signing. This can produce in an encrypted file that's smaller than the original.

Resolves

Resolves #230

Details

  • Compress before encryption / decompress after decryption
  • Use gzip compression
  • About 30% reduction observed

Testing

I manually tested node encrypt, node decrypt, and HTML wrapper decrypt.

Notes for Reviewers

In an attempt to avoid, or at least limit, having 3 representations of data simultaneously in memory (file data buffer, decrypted data buffer, decompressed data buffer), we sometimes pass a reader instead of a buffer. Reader here means a callable that can read the data. See 'msgReader' in codec.js, which provides this comment:

We take a message reader function instead of a message buffer so we can release its storage when it is no longer needed (caller isn't stuck holding a reference).

jimhark avatar Jul 21 '25 08:07 jimhark

Committed a396bf05a52ec6cbbc8f7cd606086b5c4a6dcdc8 to fix line of code that got messed up between testing and commit/push.

jimhark avatar Jul 23 '25 06:07 jimhark

Committed a396bf05a52ec6cbbc8f7cd606086b5c4a6dcdc8 to remove to variable definitions for vars that are no longer used. This was discovered while writing a previous pull request comment.

jimhark avatar Jul 23 '25 06:07 jimhark