npm.io
1.0.8 • Published yesterday

@xchainjs/xchain-crypto

Licence
MIT
Version
1.0.8
Deps
3
Size
27 kB
Vulns
1
Weekly
0
Stars
133

XChain Crypto

NPM Version NPM Downloads


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

yarn add @xchainjs/xchain-crypto

or

npm install @xchainjs/xchain-crypto

Documentation

xchain crypto

How xchain-crypto works
How to use xchain-crypto

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
// 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
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
}