Consider streaming decryption/write path to reduce peak memory usage for large files

Offen
#1,776 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Ruhig
Tech-Stack
javascript

Rechercherichtung

Start by locating the download verification/decryption flow that accumulates chunks[], calls concatBytes(...chunks), and allocates Uint8Array(pLen), then read the streaming primitives sbInit and sbDecryptChunk. The issue does not define an implementation scope; clarify the architecture and acceptance criteria for incremental writes, final authentication failure cleanup, padding/header parsing, and resumable downloads before coding.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

I noticed the current download verification/decryption flow buffers the full encrypted file into memory before decrypting.

Current flow appears to:

accumulate encrypted chunks in chunks[]
concatenate them via concatBytes(...chunks)
allocate another full plaintext buffer with new Uint8Array(pLen)

This can significantly increase peak memory usage for large files, especially on mobile browsers.

The crypto layer itself already seems stream-capable (sbInit, sbDecryptChunk, incremental Poly1305 state), so I was wondering whether a more streaming-oriented architecture could be considered in the future.

Possible direction:

download chunk
→ decrypt incrementally
→ write plaintext directly to OPFS/temp storage
→ finalize/verify auth tag at end

This could reduce peak RAM usage from approximately full-file-size multiples down to near chunk-size memory usage.

I understand there are important tradeoffs around:

final authentication validation
temporary storage cleanup on auth failure
padding/header parsing
resumable download behavior

So I wanted to ask whether this direction would be desirable before experimenting with an implementation.

Vorherrschende Sprache
Haskell
Sterne
865
Forks
125
Ø Merge
1 T. 20 Std.
Gemergte PRs (30 T.)
64

Entwicklungsumgebung

  • Enthält ein Dockerfile oder eine Docker-Compose-Datei
  • Keine Pull-Request-Vorlage
  • Beitragsleitfaden lesen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus simplex-chat/simplexmq

Alle Issues in simplex-chat/simplexmq

Ähnliche Issues

Weitere Issues zu Haskell

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.