2.0.0 • Published 3 years ago

@cere/cere-signer v2.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Description

This lib provides an ability to sign data and verify signed data using blake2b algorithm.

Release Notes

v1.3.3

  • Updated permission

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);

// after that inside our object a new field called 'signature' will be appeared
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: {} };

// we can provide any additional fields as varargs. Order is important!
signObject(obj, 'id', 'event_type', 'payload');

// after that inside our object a new field called 'signature' will be appeared
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); // result as boolean
import { verifySignature } from '@cere-io/cere-signer';

const signature = 'sig';
const obj = { id: 1, event_type: 'checkin', payload: {} };

// the order of fields is important! use the same order as you provided to signObject method.
const res = verifySignature(obj, signature, 'id', 'event_type', 'payload'); // result as boolean
2.0.0

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

4 years ago

1.3.1-beta.0

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.2.0-rc7

5 years ago

1.2.0-rc6

5 years ago

1.2.0-rc5

5 years ago

1.2.0-rc4

5 years ago

1.2.0-rc3

5 years ago

1.2.0-rc2

5 years ago

1.2.0-rc1

5 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago