Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
fix: Imports key-composer for tree shaking and silences lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoElias committed Apr 23, 2019
1 parent aa11916 commit ac3b044
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const bs58 = require('bs58')
const multihashing = require('multihashing-async')
const keyComposer = require('crypto-key-composer')
const { composePrivateKey, decomposePrivateKey } = require('crypto-key-composer')

module.exports = (keysProtobuf, randomBytes, crypto) => {
crypto = crypto || require('./crypto')(randomBytes)
Expand Down Expand Up @@ -118,7 +118,7 @@ module.exports = (keysProtobuf, randomBytes, crypto) => {
const decompressedPublicKey = typedArrayToUint8Array(crypto.decompressPublicKey(this.public._key))
try {
if (format === 'pkcs-8') {
pem = keyComposer.composePrivateKey({
pem = composePrivateKey({
format: 'pkcs8-pem',
keyAlgorithm: {
id: 'ec-public-key',
Expand Down Expand Up @@ -183,7 +183,7 @@ module.exports = (keysProtobuf, randomBytes, crypto) => {
function importPEM (pem, password, callback) {
let privkey
try {
const decomposedPrivateKey = keyComposer.decomposePrivateKey(pem, { password })
const decomposedPrivateKey = decomposePrivateKey(pem, { password })
privkey = new Secp256k1PrivateKey(Buffer.from(decomposedPrivateKey.keyData.d))
} catch (err) { return callback(err) }

Expand Down
2 changes: 2 additions & 0 deletions test/secp256k1.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ describe('secp256k1 keys', () => {
})
})

/* eslint-disable */
describe('import and export', () => {
it('password protected PKCS #8', (done) => {
key.export('pkcs-8', 'my secret', (err, pem) => {
Expand Down Expand Up @@ -178,6 +179,7 @@ describe('secp256k1 keys', () => {
})
})
})
/* eslint-enable */
})

describe('key generation error', () => {
Expand Down

0 comments on commit ac3b044

Please sign in to comment.