Files
common/packages/util-keyring/src/decrypt.spec.js
T
Jaco Greeff 35d2f69b75 Pkcs8 bytes for pairs (non-encrypted) (#111)
* Upgrade dependencies

* Pkcs8 bytes for pairs (non-encrypted)

* Bump minor

* Pass only secretKey around for encoding

* Cleanup seed interface
2018-03-20 15:42:39 +01:00

30 lines
886 B
JavaScript

// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
const u8aFromString = require('@polkadot/util/u8a/fromString');
const index = require('./index');
describe('decrypt', () => {
const publicKey = new Uint8Array([47, 140, 97, 41, 216, 22, 207, 81, 195, 116, 188, 127, 8, 195, 230, 62, 209, 86, 207, 120, 174, 251, 74, 101, 80, 217, 123, 135, 153, 121, 119, 238]);
const seedOne = u8aFromString('12345678901234567890123456789012');
let keypair;
let encrypted;
beforeEach(() => {
keypair = index();
keypair.addFromSeed(seedOne);
encrypted = keypair.encrypt(publicKey, 'test');
keypair = index();
});
it('decrypts a previously encrypted', () => {
expect(
keypair.decrypt(encrypted, 'test').publicKey()
).toEqual(publicKey);
});
});