# zetrix-encryption-nodejs

> zetrix-encryption

Latest version **1.1.0** (published 2026-04-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install zetrix-encryption-nodejs
pnpm add zetrix-encryption-nodejs
yarn add zetrix-encryption-nodejs
bun add zetrix-encryption-nodejs
```

## Health

**Score 53/100 (C)** — status: active.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-04-21 |
| First published | 2022-01-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/zetrix-encryption-nodejs) |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 285.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | zetrix |
| Maintainers | zetrix-chain, maslan501, izadimrantan |
| Keywords | zetrix, zetrix-encryption |

## Links

- npm: https://www.npmjs.com/package/zetrix-encryption-nodejs
- npm.io page: https://npm.io/package/zetrix-encryption-nodejs

## Dependencies (7)

- [long](https://npm.io/package/long.md) ^5.3.2
- [sha3](https://npm.io/package/sha3.md) ^2.1.4
- [sjcl](https://npm.io/package/sjcl.md) ^1.0.7
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.2.0
- [sm-crypto](https://npm.io/package/sm-crypto.md) ^0.3.13
- [is-type-of](https://npm.io/package/is-type-of.md) ^1.2.0
- [randombytes](https://npm.io/package/randombytes.md) ^2.1.0

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2026-04-21
- 1.0.2 — 2026-04-20
- 1.0.1 — 2025-04-11
- 1.0.0 — 2022-01-12

## README

zetrix-encryption-nodejs
=======

## zetrix-encryption-nodejs  Installation
```
npm install zetrix-encryption-nodejs --save
```

## zetrix-encryption-nodejs  Test
```
npm test
```

## zetrix-encryption-nodejs  Usage

```js
'use strict';

const encryption = require('zetrix-encryption-nodejs');

const KeyPair = encryption.keypair;
const signature = encryption.signature;
const keystore = encryption.keystore;

let kp = new KeyPair();
// Get encPrivateKey, encPublicKey, address
let encPrivateKey = kp.getEncPrivateKey();
let encPublicKey = kp.getEncPublicKey();
let address = kp.getAddress();


console.log('============= bof: ==============');
console.log(`EncPrivateKey is : ${encPrivateKey}`);
console.log(`EncPublicKey is : ${encPublicKey}`);
console.log(`Address hash is : ${address}`);
console.log('============= eof: ==============');

// Get keypair
let keypair = KeyPair.getKeyPair();

// Get encPublicKey
let encPublicKey = KeyPair.getEncPublicKey(encPrivateKey);

// Get address
let address = KeyPair.getAddress(encPublicKey);

// check encPrivateKey
KeyPair.checkEncPrivateKey(encPrivateKey);

// check encPublicKey
KeyPair.checkEncPublicKey(encPublicKey);

// check address
KeyPair.checkAddress(address);

// signature sign and verify
let sign = signature.sign('test', encPrivateKey);
let verify = signature.verify('test', sign, encPublicKey);

// keystore
keystore.encrypt(encPrivateKey, 'test', function(encData) {
  keystore.decrypt(encData, 'test', function(descData) {
    console.log(descData);
  });
});

```

## Supported algorithms

Pass one of the following strings to `new KeyPair(signType)` or `KeyPair.getKeyPair(signType)`:

| `signType`   | Sign-type byte | Address-type byte | Address prefix |
|--------------|----------------|-------------------|----------------|
| `ed25519` (default) | `0x01` | `0x01` | `ZTX3` |
| `sm2`               | `0x02` | `0x02` | `ZTX3` |
| `dilithium3`        | `0x05` | `0x04` | `ZTX4` |
| `hybrid` (ED25519 + Dilithium3) | `0x06` | `0x06` | `ZTX5` |

### Notes on the Dilithium3 variant

The bundled Dilithium3 implementation (`lib/vendor/dilithium3-fips204/`) uses FIPS 204 / ML-DSA-65 parameter sizes (private key 4032 B, public key 1952 B, signature 3309 B) but **omits the FIPS 204 message-domain-separation prefix**. Signatures produced by this library are interoperable with the deployed Zetrix blockchain but are **not interoperable with spec-compliant ML-DSA-65 verifiers**.

The sign-type byte (`0x05`) and address-type byte (`0x04`) intentionally differ for Dilithium3. The mismatch preserves a stable `ZTX4` address prefix while keeping the `0x04` sign-type slot reserved (it was previously used for CFCA and is no longer valid — see `lib/constants.js`).

### Hybrid mode

`hybrid` keys sign twice (ED25519 + Dilithium3) and verification requires **both** signatures to pass. This provides defence-in-depth: classical forgery requires breaking ED25519, and post-quantum forgery requires breaking Dilithium3.

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/zetrix-encryption-nodejs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
