@theqrl/hashchains v0.6.1
@theqrl/hashchains
There's a live demo on Codepen to show the package in use.
Browser bundle at dist/hashchains-browser.js
Modules in dist but installing the npm release and import/requiring @theqrl/hashchains should work with modern toolsets, i.e:
npm install @theqrl/hashchainsimport { HashChain, HashChains } from '@theqrl/hashchains'Exposes two classes:
1. HashChain
const hc = new HashChain(hashRoot, hashFunction, length)hashRoot (string)
required
The hash of (secret data + index) which forms the first hash in the chain and is iteratively hashed.
hashFunction (string)
optional, default 'keccack256'
Currently only keccak256 is implemented.
length
optional, default 64
Number of hashes to generate in the chain.
2. HashChains
const hc = new HashChains(mnemonic, numberToCreate, index, hashFunction, length)mnemomic
required
Secret data (eg. BIP39 mnemonic or hexstring) which is hashed along with sequential index to be the start of the hashchains.
numberToCreate
optional, default 2
Number of hashchains to return
index
optional, default 0
Starting index for hashchains. Starting at index 0 and generating 10 chains then starting at index 8 and generating 5 chains will create two overlapping (i.e. identical) hashchains.
hashFunction (string)
optional, default 'keccack256'
Currently only keccak256 is implemented.
length
optional, default 64
Number of hashes to generate per chain created.
Also in this repository
After an npm install:
Live demo
npm run serveStarts a local vue development environment serving the browser-based demo from the CodePen above. This may be useful in adding more functionality/hash functions.
Tests
npm run testDev environment
npm run devRuns a watched for continuous development: lint code as per repository standards and ensure test cases pass.
Build
npm run buildOutputs cjs/umd/esm and browserified JS modules to dist/ directory.