nightlite-utils
v1.0.6
Published
A utility package for common math and formatting functions
Downloads
12
Readme
zkp-utils
This library contains many utility functions for use in zkp applications.
Install
In your NodeJS project:npm i zkp-utils
Functions
- number-conversions
- hex
strip0x, ensure0x, isHex, requireHex, leftPadHex, truncateHex, resizeHex, hexToUtf8, hexToAscii, hexToBinArray, hexToBin, hexToBytes, hexToDec, hexToField, hexToLimbs, hexToDecLimbs, hexToBinLimbs, randomHex,
- decimal
decToHex, decToBin, decToBinLimbs,
- binary
binToHex, binToDec, binToLimbs,
- char
utf8StringToHex, asciiToHex,
- hex
- hashes
- sha256
shaHash;
- mimc
mimcHash;
- sha256
Developer
Test
Clone the repo. npm i
npm test
Test with yalc
If you've made local changes to this repo, and would like to test whether those (unpublished) changes will work with some dependent zkp appliation (zApp)...
...then you’ll need to install your local, ‘branched’ version of zkp-utils
in your zApp.
cd path/to/zkp-utils/
yalc publish
You should see something like "@eyblockchain/[email protected] published in store.
". Notice the ‘signature’ 3df45b8c
.
cd path/to/your/zApp/
Remove the package-lock.json and the node_modules from your zApp's root (if they exist on your machine).
Then:
yalc add @eyblockchain/zkp-utils
You’ll see that this has ‘swapped-in’ the ‘published’ (yalc version) of zkp-utils
in the package.json
. It’s also created .yalc.lock
(which shows that you’ve replaced the ‘proper’ npm package of zkp-utils
with your ‘yalc version’ (see the signature
field in this file, which should match the signature from earlier)).
Now install node modules:
npm i
If your zApp runs in a container, then you might need to also edit its dockerfile:
Change a line in <your zApp>/Dockerfile
from RUN npm ci
to RUN npm install
.
Add a line in <your zApp>/docker-compose.yml
:
yourService:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./.yalc:/app/.yalc # <<< ADD THIS LINE (or something similar)!!!
When you're happy that your local changes to zkp-utils
work and you wish to create a PR, you MUST remove any references to yalc
, or the PR shouldn't be accepted.