Documentation Index
Fetch the complete documentation index at: https://docs.kynesys.xyz/llms.txt
Use this file to discover all available pages before exploring further.
L2PS SDK
Layer 2 Privacy Subnets (L2PS) are encrypted execution lanes that ride on top of the main Demos Network. Transactions submitted to a subnet are encrypted with AES-GCM before they reach the mempool, batched, proven, and confirmed without revealing their contents to non-members. The architecture and lifecycle live in L2PS Privacy Subnets. This page documents the SDK surface used by clients to encrypt transactions for a subnet they belong to. The L2PS module is exported from@kynesyslabs/demosdk/l2ps.
Creating an L2PS instance
L2PS.create(privateKey?, iv?) is the factory method. Each instance is a participant in one subnet, identified by the SHA-256 of its private key. Random keys are generated if you don’t provide your own.
| Parameter | Type | Required | Description |
|---|---|---|---|
privateKey | string | no | AES-256 private key. 32 random bytes are generated if omitted. |
iv | string | no | AES-GCM initialization vector. 12 random bytes are generated if omitted. |
Encrypting a transaction
encryptTx(tx, senderIdentity?) takes an ordinary signed Transaction and wraps it in a new transaction of type "l2psEncryptedTx". The original payload is serialized, encrypted with AES-GCM, base64-encoded, and stored alongside the auth tag and a hash of the original transaction for integrity verification.
L2PSEncryptedPayload:
senderIdentity parameter overrides the from field on the encrypted wrapper — useful when subnet members want to obscure the originating address from non-members.
Decrypting a transaction
Subnet members verify and decrypt incoming traffic withdecryptTx:
Instance registry
L2PS instances are registered in a static map keyed by their ID (SHA-256 of the private key). Useful when a process participates in multiple subnets:| Method | Returns | Purpose |
|---|---|---|
L2PS.getInstance(id) | L2PS | undefined | Look up an instance by ID. |
L2PS.getInstances() | L2PS[] | List all active instances. |
L2PS.hasInstance(id) | boolean | Existence check. |
L2PS.removeInstance(id) | boolean | Remove from the registry. Returns true if removed, false if not found. |
Configuration object
You can attach anL2PSConfig to an instance to associate it with a subnet UID and known RPC endpoints:
encryptTx uses config.uid as the l2ps_uid on the encrypted payload. Otherwise the instance ID (SHA-256) is used.
Related documentation
- L2PS Privacy Subnets (Backend) — architecture, batch lifecycle, ZK-proof aggregation.
- How L2PS Transactions Are Handled — node-side processing of
l2psEncryptedTx. - L2PS Quickstart — running an L2PS subnet end-to-end.