@polkadot/util-keyring
Advanced tools
Comparing version 0.18.3 to 0.18.4
{ | ||
"name": "@polkadot/util-keyring", | ||
"version": "0.18.3", | ||
"version": "0.18.4", | ||
"description": "Keyring management", | ||
@@ -34,6 +34,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"@polkadot/util": "^0.18.3", | ||
"@polkadot/util-crypto": "^0.18.3", | ||
"@polkadot/util": "^0.18.4", | ||
"@polkadot/util-crypto": "^0.18.4", | ||
"babel-runtime": "^6.26.0" | ||
} | ||
} |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var u8aConcat = require('@polkadot/util/u8a/concat'); | ||
var assert = require('@polkadot/util/assert'); | ||
var naclFromSeed = require('@polkadot/util-crypto/nacl/keypair/fromSeed'); | ||
@@ -21,7 +23,11 @@ var _require = require('./defaults'), | ||
var seed = encoded.subarray(SEED_OFFSET, SEED_OFFSET + KEY_LENGTH); | ||
var secretKey = u8aConcat(seed, publicKey); | ||
var validate = naclFromSeed(seed); | ||
assert(validate.publicKey.toString() === publicKey.toString(), 'Pkcs8 decoded keys are not matching'); | ||
return { | ||
publicKey: publicKey, | ||
secretKey: u8aConcat(seed, publicKey) | ||
secretKey: secretKey | ||
}; | ||
}; |
'use strict'; | ||
// Copyright 2017-2018 Jaco Greeff | ||
var naclSign = require('@polkadot/util-crypto/nacl/sign'); // 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. | ||
var naclFromSeed = require('@polkadot/util-crypto/nacl/keypair/fromSeed'); | ||
var naclSign = require('@polkadot/util-crypto/nacl/sign'); | ||
var naclVerify = require('@polkadot/util-crypto/nacl/verify'); | ||
var assert = require('@polkadot/util/assert'); | ||
var decode = require('./decode'); | ||
var encode = require('./encode'); | ||
var _getMeta = require('./getMeta'); | ||
var _setMeta = require('./setMeta'); | ||
function _decodePkcs(encoded, passphrase) { | ||
var _decode = decode(encoded, passphrase), | ||
publicKey = _decode.publicKey, | ||
secretKey = _decode.secretKey; | ||
var validate = naclFromSeed(secretKey.subarray(0, 32)); | ||
assert(validate.publicKey.toString() === publicKey.toString(), 'Pkcs8 decoded keys are not matching'); | ||
return { | ||
publicKey: publicKey, | ||
secretKey: secretKey | ||
}; | ||
} | ||
module.exports = function pair(_ref) { | ||
@@ -33,5 +19,9 @@ var _publicKey = _ref.publicKey, | ||
var state = { | ||
meta: {} | ||
}; | ||
return { | ||
decodePkcs8: function decodePkcs8(encoded, passphrase) { | ||
var decoded = _decodePkcs(encoded, passphrase); | ||
var decoded = decode(encoded, passphrase); | ||
@@ -44,5 +34,11 @@ _publicKey = decoded.publicKey; | ||
}, | ||
getMeta: function getMeta() { | ||
return _getMeta(state); | ||
}, | ||
publicKey: function publicKey() { | ||
return _publicKey; | ||
}, | ||
setMeta: function setMeta(meta) { | ||
return _setMeta(state, meta); | ||
}, | ||
sign: function sign(message) { | ||
@@ -49,0 +45,0 @@ return naclSign(message, secretKey); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21525
30
200
Updated@polkadot/util@^0.18.4