How to Use
Installation
yarn add @xchainjs/xchain-cryptoDevelopment
Build
yarn buildTests
yarn testExample
Generate New Phrases and Encrypt
// Imports
import { generatePhrase, validatePhrase, encryptToKeyStore, decryptFromKeystore } from "@xchainjs/xchain-crypto"
require('dotenv').config();
const keystore1 = JSON.parse(fs.readFileSync('keystore.json', 'utf8'))
const password = process.env.PASSWORD
// Generate Keystore and save it to a keystore file
const GenerateKeystore = async () => {
const phrase = generatePhrase()
console.log(`phrase ${phrase}`)
const isCorrect = validatePhrase(phrase) //validate phrase if needed returns Boolean
console.log(`Phrase valid?: ${isCorrect}`)
const keystore = await encryptToKeyStore(phrase, password)
fs.writeFileSync(`./keystore.json`, JSON.stringify(keystore, null, 4), 'utf8')
}Decrypt Keystore to Retrieve a Phrase
Retrieve Seed
Keystore Type
Constants
Last updated