UNPKG

@crpdo/key

Version:

Streamlines key generation, derivation, and management through its simple and intuitive API

46 lines (39 loc) 1.3 kB
const SignKey = require('../lib/sign-key') const BaseKey = require('../lib/base-key') const seed = 'seed' const data = 'foo' const signature = '2beEgxbfJsxiAxuRcKnhx9mGL2uhFzmmcqCNj3SWDKCJ4pYYZGpcRpVawGnmCcGsnYKd8zhKCV9T76A5KoiVYoX7' describe('SignKey', () => { const signKey = new SignKey(seed) describe('#constructor()', () => { it('should create a SignKey object with valid seed', () => { expect(signKey).to.be.an('object') expect(signKey).to.be.an.instanceOf(SignKey) expect(signKey).to.be.an.instanceOf(BaseKey) }) }) describe('#sign()', () => { it('should sign the data', () => { const signature = signKey.sign(data) expect(signature).to.be.an('string') }) }) describe('#verify()', () => { it('should verify the signature', () => { const isValidSignature = signKey.verify(data, signature, signKey.publicKey) expect(isValidSignature).to.be.true }) }) describe('#publicKey', () => { it('should get the public key', () => { const publicKey = signKey.publicKey expect(publicKey).to.be.a('string') }) }) describe('#privateKey', () => { it('should get the private key', () => { const privateKey = signKey.privateKey expect(privateKey).to.be.a('string') }) }) })