libp2p-crypto
Advanced tools
Comparing version 0.17.7 to 0.17.8
@@ -0,1 +1,11 @@ | ||
<a name="0.17.8"></a> | ||
## [0.17.8](https://github.com/libp2p/js-libp2p-crypto/compare/v0.17.7...v0.17.8) (2020-07-20) | ||
### Bug Fixes | ||
* go ed25519 interop ([2f18a07](https://github.com/libp2p/js-libp2p-crypto/commit/2f18a07)) | ||
<a name="0.17.7"></a> | ||
@@ -2,0 +12,0 @@ ## [0.17.7](https://github.com/libp2p/js-libp2p-crypto/compare/v0.17.6...v0.17.7) (2020-06-09) |
{ | ||
"name": "libp2p-crypto", | ||
"version": "0.17.7", | ||
"version": "0.17.8", | ||
"description": "Crypto primitives for libp2p", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -92,5 +92,13 @@ 'use strict' | ||
function unmarshalEd25519PrivateKey (bytes) { | ||
bytes = ensureKey(bytes, crypto.privateKeyLength + crypto.publicKeyLength) | ||
// Try the old, redundant public key version | ||
if (bytes.length > crypto.privateKeyLength) { | ||
bytes = ensureKey(bytes, crypto.privateKeyLength + crypto.publicKeyLength) | ||
const privateKeyBytes = bytes.slice(0, crypto.privateKeyLength) | ||
const publicKeyBytes = bytes.slice(crypto.privateKeyLength, bytes.length) | ||
return new Ed25519PrivateKey(privateKeyBytes, publicKeyBytes) | ||
} | ||
bytes = ensureKey(bytes, crypto.privateKeyLength) | ||
const privateKeyBytes = bytes.slice(0, crypto.privateKeyLength) | ||
const publicKeyBytes = bytes.slice(crypto.privateKeyLength, bytes.length) | ||
const publicKeyBytes = bytes.slice(crypto.publicKeyLength) | ||
return new Ed25519PrivateKey(privateKeyBytes, publicKeyBytes) | ||
@@ -115,8 +123,6 @@ } | ||
function ensureKey (key, length) { | ||
if (Buffer.isBuffer(key)) { | ||
key = new Uint8Array(key) | ||
key = Uint8Array.from(key || []) | ||
if (key.length !== length) { | ||
throw errcode(new Error(`Key must be a Uint8Array or Buffer of length ${length}, got ${key.length}`), 'ERR_INVALID_KEY_TYPE') | ||
} | ||
if (!(key instanceof Uint8Array) || key.length !== length) { | ||
throw errcode(new Error('Key must be a Uint8Array or Buffer of length ' + length), 'ERR_INVALID_KEY_TYPE') | ||
} | ||
return key | ||
@@ -123,0 +129,0 @@ } |
@@ -81,4 +81,3 @@ 'use strict' | ||
* | ||
* @param {function(Error, id)} callback | ||
* @returns {undefined} | ||
* @returns {Promise<string>} | ||
*/ | ||
@@ -85,0 +84,0 @@ async id () { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1575
0
474186