Description
This lib provides an ability to sign data and verify signed data using blake2b algorithm.
Release Notes
v1.3.3
v1.3.0
- Change Stub signature to properly generated by user's private key
v1.2.0
- Added substrate signer function
Installation
nvm exec npm i
Test
nvm exec npm test
Using
Sign whole object
import { signObject } from '@cere-io/cere-signer';
const obj = { id: 1 };
signObject(obj);
console.log(obj.signature);
Sign object with pointing a sequence of fields
import { signObject } from '@cere-io/cere-signer';
const obj = { id: 1, event_type: 'checkin', payload: {} };
signObject(obj, 'id', 'event_type', 'payload');
console.log(obj.signature);
Verify signature
Here we use the same approach as above: we can verify a whole object as well as provide a sequence of fields:
import { verifySignature } from '@cere-io/cere-signer';
const signature = 'sig';
const obj = { id: 1 };
const res = verifySignature(obj, signature);
import { verifySignature } from '@cere-io/cere-signer';
const signature = 'sig';
const obj = { id: 1, event_type: 'checkin', payload: {} };
const res = verifySignature(obj, signature, 'id', 'event_type', 'payload');