22
33[ ![ Quality gate] ( https://github.com/zeroledger/vycrypt/actions/workflows/quality-gate.yml/badge.svg )] ( https://github.com/zeroledger/vycrypt/actions/workflows/quality-gate.yml )
44
5-
6-
7- TypeScript Development Kit for ZeroLedger Protocol - A comprehensive cryptographic library for stealth addresses and ECDH encryption.
5+ Crypto primitives for ZeroLedger Protocol - A comprehensive cryptographic library for stealth addresses and ECDH encryption. Pure ESM, optimized for modern JavaScript environments.
86
97* Warning* : Software provided as is and has not passed any security checks and reviews.
108
@@ -29,30 +27,25 @@ TypeScript Development Kit for ZeroLedger Protocol - A comprehensive cryptograph
2927npm install @zeroledger/vycrypt
3028```
3129
32- ## Module Formats
33-
34- This library supports both ** CommonJS** and ** ES Modules** formats for maximum compatibility:
30+ ## Module Format
3531
36- - ** CommonJS** : For Node.js environments and bundlers that prefer CommonJS
37- - ** ES Modules** : For modern bundlers and environments that support ES modules
32+ This library is ** pure ESM** (ES Modules) and requires ** Node.js 20.19.0 or later** .
3833
39- The library automatically provides the appropriate format based on your import method:
34+ ** Import the library: **
4035
4136``` typescript
42- // ES Modules (recommended for modern projects)
43- import { encrypt , decrypt } from " @zeroledger/vycrypt" ;
44-
45- // CommonJS (for legacy Node.js or specific bundler requirements)
46- const { encrypt, decrypt } = require (" @zeroledger/vycrypt" );
37+ import { encrypt , decrypt } from " @zeroledger/vycrypt/crypt.js" ;
38+ import { createStealth , deriveStealthAccount } from " @zeroledger/vycrypt/stealth.js" ;
4739```
4840
4941### Build Output
5042
51- The library builds to two directories:
52- - ` cjs/ ` - CommonJS format with ` .js ` files
53- - ` esm/ ` - ES Modules format with ` .js ` files and ` package.json `
43+ The library builds directly to the root directory with ESM format:
44+ - ` *.js ` - ES Module JavaScript files
45+ - ` *.d.ts ` - TypeScript declaration files
46+ - ` stealth/ ` - Stealth address modules
5447
55- Both formats include TypeScript declaration files (` .d.ts ` ) for full type support .
48+ All files include source maps (` .js.map ` , ` . d.ts.map ` ) for debugging .
5649
5750## API Reference
5851
@@ -119,7 +112,7 @@ Multiplies a private key by a scalar value.
119112### Basic Encryption/Decryption
120113
121114``` typescript
122- import { encrypt , decrypt } from " @zeroledger/vycrypt" ;
115+ import { encrypt , decrypt } from " @zeroledger/vycrypt/crypt.js " ;
123116import { generatePrivateKey , privateKeyToAccount } from " viem/accounts" ;
124117
125118// Generate key pair
@@ -138,7 +131,7 @@ console.log(decryptedData); // "Hello, World!"
138131### Stealth Address Creation
139132
140133``` typescript
141- import { createStealth , deriveStealthAccount } from " @zeroledger/vycrypt" ;
134+ import { createStealth , deriveStealthAccount } from " @zeroledger/vycrypt/stealth.js " ;
142135import { generatePrivateKey , privateKeyToAccount } from " viem/accounts" ;
143136import { toHex } from " viem" ;
144137
@@ -158,7 +151,7 @@ console.log("Derived Address:", account.address); // Same as stealthAddress
158151### Elliptic Curve Operations
159152
160153``` typescript
161- import { mulPublicKey , mulPrivateKey } from " @zeroledger/vycrypt" ;
154+ import { mulPublicKey , mulPrivateKey } from " @zeroledger/vycrypt/stealth.js " ;
162155import { generatePrivateKey , privateKeyToAccount } from " viem/accounts" ;
163156
164157const privateKey = generatePrivateKey ();
@@ -179,7 +172,7 @@ console.log(newAccount.publicKey === newPublicKey); // true
179172### Advanced: Encrypting Large Data
180173
181174``` typescript
182- import { encrypt , decrypt } from " @zeroledger/vycrypt" ;
175+ import { encrypt , decrypt } from " @zeroledger/vycrypt/crypt.js " ;
183176import { generatePrivateKey , privateKeyToAccount } from " viem/accounts" ;
184177
185178const privKey = generatePrivateKey ();
@@ -250,12 +243,25 @@ Run tests with:
250243npm test
251244```
252245
246+ Validate build output and ESM imports:
247+ ``` bash
248+ npm run test:build
249+ ```
250+
251+ This command:
252+ 1 . Builds the library
253+ 2 . Validates all expected files are created
254+ 3 . Verifies built modules can be imported as ESM
255+ 4 . Confirms the API works as documented
256+
253257## Dependencies
254258
255- - ** @noble/curves ** : For secp256k1 elliptic curve operations
256- - ** @noble/ciphers ** : For AES-256-GCM encryption
257- - ** @noble/hashes ** : For SHA-256 hashing
258- - ** viem** : For Ethereum-compatible utilities and types
259+ - ** @noble/ciphers ** (v2.0.1): AES-256-GCM authenticated encryption
260+ - ** viem** (v2.38.6): Ethereum-compatible utilities, types, and hashing (SHA-256)
261+
262+ ** Note:** Viem internally uses and re-exports ` @noble/curves ` (secp256k1) and ` @noble/hashes ` , ensuring compatibility across the ecosystem.
263+
264+ All dependencies are ESM-compatible and actively maintained.
259265
260266## Contributing
261267
@@ -278,16 +284,16 @@ npm test
278284
279285### Building
280286
281- To build both CommonJS and ES Module versions :
287+ To build the ESM output :
282288
283289``` bash
284290npm run build
285291```
286292
287293This creates:
288- - ` cjs/ ` directory with CommonJS files
289- - ` esm /` directory with ES Module files
290- - TypeScript declaration files (` .d.ts ` ) for both formats
294+ - ` *.js ` files in the root directory (ESM format)
295+ - ` stealth /` directory with stealth modules
296+ - TypeScript declaration files (` .d.ts ` ) and source maps
291297
292298### Type Checking
293299
0 commit comments