Skip to content

Performance: WASM decryption is 2.3x slower than JS SDK #44

@arkavo-com

Description

@arkavo-com

Summary

WASM SDK decryption performance is significantly slower than the JS SDK, taking 466.5ms compared to JS SDK's 202.7ms (2.3x slower).

Benchmark Environment

  • Platform: macOS (Apple Silicon)
  • Browser: Chromium 141.0.7390.37
  • Test Message: 39 bytes
  • Network: localhost (minimal latency)
  • Test Framework: Playwright E2E

Performance Metrics

Implementation Decryption Time
JS SDK 202.7ms
WASM 466.5ms
Difference +130% slower

Analysis

The WASM decryption includes:

  • Full KAS rewrap protocol
  • RSA-OAEP key unwrapping
  • JWT signing with ES256
  • AES-256-GCM decryption

Suspected bottlenecks:

  1. JWT signing operations - May not be optimized
  2. RSA key operations - Potentially using slower algorithms
  3. Network requests - Possibly not reusing connections
  4. Token caching - May not be caching KAS responses

Expected Outcome

WASM should match or exceed JS SDK performance for decryption, ideally:

  • Target: <200ms for 39-byte payload
  • Stretch goal: <150ms (faster than JS SDK)

Suggested Optimizations

  1. Connection Pooling: Reuse HTTP connections to KAS
  2. Token Caching: Cache KAS rewrap responses where possible
  3. Crypto Optimization: Use browser's WebCrypto API via wasm-bindgen where appropriate
  4. JWT Optimization: Optimize ES256 signing performance
  5. Async Operations: Ensure all I/O is truly non-blocking

Test Repository

Full benchmark available at: wasm-vs-js comparison app

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions