# @xchainjs/xchain-crypto

> XChain Crypto is a crypto module needed by all XChain clients.

Latest version **1.0.8** (published 2026-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @xchainjs/xchain-crypto
pnpm add @xchainjs/xchain-crypto
yarn add @xchainjs/xchain-crypto
bun add @xchainjs/xchain-crypto
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2026-07-20 |
| First published | 2020-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 26.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Thorchain |
| Maintainers | xchainjsadmin, thorchain_org, _stu, veado, thatstrangeguy, junkai121, sarawut11, thorswap, hodrthemediocre, polaris_9r, thorianite |

## Links

- npm: https://www.npmjs.com/package/@xchainjs/xchain-crypto
- Repository: https://github.com/xchainjs/xchainjs-lib
- Homepage: https://github.com/xchainjs/xchainjs-lib#readme
- Issues: https://github.com/xchainjs/xchainjs-lib/issues
- npm.io page: https://npm.io/package/@xchainjs/xchain-crypto

## Dependencies (3)

- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [@scure/bip39](https://npm.io/package/@scure/bip39.md) ^1.6.0
- [@noble/hashes](https://npm.io/package/@noble/hashes.md) ^1.8.0

## Recent versions

- 1.0.8 (latest) — 2026-07-20
- 1.0.7 — 2026-06-25
- 1.0.6 — 2025-07-28
- 1.0.5 — 2025-07-23
- 1.0.4 — 2025-07-23
- 1.0.3 — 2025-07-23
- 1.0.2 — 2025-07-15
- 1.0.1 — 2025-06-23
- 1.0.0 — 2025-04-28
- 0.3.7 — 2024-12-20
- 0.3.6 — 2024-10-11
- 0.3.5 — 2024-09-25
- 0.3.4 — 2024-05-15
- 0.3.3 — 2024-05-14
- 0.3.2 — 2024-04-29
- … 12 more at https://npm.io/package/@xchainjs/xchain-crypto/versions

## README

<div align="center">
  <h1 align="center">XChain Crypto</h1>

  <p align="center">
    <a href='https://www.npmjs.com/package/@xchainjs/xchain-crypto' target='_blank'>
      <img alt="NPM Version" src="https://img.shields.io/npm/v/%40xchainjs%2Fxchain-crypto" />
    </a>
    <a href='https://www.npmjs.com/package/@xchainjs/xchain-crypto' target='_blank'>
      <img alt="NPM Downloads" src="https://img.shields.io/npm/d18m/%40xchainjs%2Fxchain-crypto" />
    </a>
  </p>
</div>

<br />

The XChain Crypto package provides cryptographic utilities used by all XChain clients. It encrypts master phrases to keystores and supports BIP39 compatible phrase import/export across wallets.

## Modules

- `crypto` - Core cryptographic functions for keystore encryption/decryption
- `types` - TypeScript type definitions for keystores and crypto operations

## Installation

```sh
yarn add @xchainjs/xchain-crypto
```

or

```sh
npm install @xchainjs/xchain-crypto
```

## Documentation

### [`xchain crypto`](http://docs.xchainjs.org/xchain-crypto/)
[`How xchain-crypto works`](http://docs.xchainjs.org/xchain-crypto/how-it-works.html)\
[`How to use xchain-crypto`](http://docs.xchainjs.org/xchain-crypto/how-to-use.html)


## Features

- **BIP39 Compatible**: Full support for BIP39 mnemonic phrases
- **Secure Encryption**: Uses AES-128-CTR with PBKDF2 (262,144 iterations)
- **Cross-Chain**: Works with all XChain client implementations
- **Keystore Export**: Compatible with other wallet formats

### Constants

```js
// Crypto Constants for xchain
const cipher = 'aes-128-ctr'
const kdf = 'pbkdf2'
const prf = 'hmac-sha256'
const dklen = 32
const c = 262144
const hashFunction = 'sha256'
const meta = 'xchain-keystore'
```

### Keystore Type

```js
export type Keystore = {
  address: string
  crypto: {
    cipher: string
    ciphertext: string
    cipherparams: {
      iv: string
    }
    kdf: string
    kdfparams: {
      prf: string
      dklen: number
      salt: string
      c: number
    }
    mac: string
  }
  id: string
  version: number
  meta: string
}
```

---
_Source: https://npm.io/package/@xchainjs/xchain-crypto · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
