Skip to content

SDK Overview

PostGuard provides two official SDKs for identity-based encryption:

  • @e4a/pg-js: JavaScript/TypeScript SDK for browsers and Node.js
  • E4A.PostGuard: .NET SDK for server-side applications

Both SDKs use the same lazy builder pattern: calling encrypt() returns a builder that captures parameters but does no work until you call a terminal method like upload() or toBytes().

Feature Comparison

FeatureJS (@e4a/pg-js).NET (E4A.PostGuard)
Encryption
File encryption (zipped)YesYes
Raw data encryptionYesYes
Streaming encryptionYesNo
Decryption
Decrypt from Cryptify UUIDYesNo
Decrypt from raw dataYesNo
Inspect metadata before decryptYesNo
Streaming decryptionYesNo
Upload
Upload to CryptifyYesYes
Email notification on uploadYesYes
Upload progress callbackYesNo
Signing
API key signingYesYes
Yivi web (QR code)YesNo
Custom session callbackYesNo
Recipients
Email addressYesYes
Email domainYesYes
Extra attributesYesYes
Email helpers
Build MIME messageYesNo
Extract ciphertext from emailYesNo
Create email envelopeYesNo
Inject MIME headersYesNo
Other
Abort / cancellation supportYes (AbortSignal)Yes (CancellationToken)
JWT caching (decryption)YesN/A
Custom HTTP headersYesYes

The .NET SDK is sending-side only: it handles encryption and upload. Decryption is handled by the receiving side via the PostGuard website or the email plugins.

Architecture

Both SDKs follow the same three-layer architecture:

+--------------------------------------------------+
|  SDK (PostGuard class)                            |
|  - encrypt() -> Sealed  (lazy builder)            |
|  - open()    -> Opened  (JS only)                 |
|  - sign / recipient / email builders              |
+--------------------------------------------------+
|  Crypto layer                                     |
|  JS:   @e4a/pg-wasm (WebAssembly)                 |
|  .NET: libpg_ffi (native P/Invoke)                |
|  - IBE (CGWKV) + IBS (GG) + AES-128-GCM          |
+--------------------------------------------------+
|  Backend services                                 |
|  - PKG: key issuance, Yivi session management     |
|  - Cryptify: encrypted file storage + delivery    |
+--------------------------------------------------+

The PKG (Private Key Generator) is the identity-based encryption server. It issues user secret keys after verifying identity attributes through Yivi, and provides the master public key for encryption.

Cryptify is an optional file storage and email delivery service. It stores encrypted files and can send notification emails to recipients.