Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crypto-ld

Package Overview
Dependencies
Maintainers
5
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crypto-ld - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

7

CHANGELOG.md
# crypto-ld ChangeLog
## 3.3.0 - 2019-02-21
### Changed
- Improve error handling related to the decoding of key material in
`Ed25519KeyPair`. This is helpful when dealing with key material that may
be provided via command line or web UI.
## 3.2.0 - 2019-02-19

@@ -4,0 +11,0 @@

83

lib/Ed25519KeyPair.js

@@ -188,3 +188,7 @@ /*!

// (multicodec ed25519-pub 0xed01 + key bytes)
const pubkeyBytes = base58.decode(this.publicKeyBase58);
const pubkeyBytes = _base58Decode({
decode: base58.decode,
keyMaterial: this.publicKeyBase58,
type: 'public'
});
buffer.putBytes(forge.util.hexToBytes('ed01'));

@@ -212,4 +216,22 @@ buffer.putBytes(pubkeyBytes.toString('binary'));

}
const fingerprintBuffer = base58.decode(fingerprint.slice(1));
const publicKeyBuffer = base58.decode(this.publicKeyBase58);
let fingerprintBuffer;
try {
fingerprintBuffer = _base58Decode({
decode: base58.decode,
keyMaterial: fingerprint.slice(1),
type: `fingerprint's`
});
} catch(e) {
return {error: e, valid: false};
}
let publicKeyBuffer;
try {
publicKeyBuffer = _base58Decode({
decode: base58.decode,
keyMaterial: this.publicKeyBase58,
type: 'public'
});
} catch(e) {
return {error: e, valid: false};
}

@@ -246,3 +268,7 @@ // validate the first two multicodec bytes 0xed01

const bs58 = require('bs58');
const privateKey = bs58.decode(key.privateKeyBase58);
const privateKey = _base58Decode({
decode: bs58.decode,
keyMaterial: key.privateKeyBase58,
type: 'private'
});
return {

@@ -259,3 +285,9 @@ async sign({data}) {

}
const privateKey = base58.decode(key.privateKeyBase58);
// browser implementation
const privateKey = _base58Decode({
decode: base58.decode,
keyMaterial: key.privateKeyBase58,
type: 'private'
});
return {

@@ -277,3 +309,7 @@ async sign({data}) {

const bs58 = require('bs58');
const publicKey = bs58.decode(key.publicKeyBase58);
const publicKey = _base58Decode({
decode: bs58.decode,
keyMaterial: key.publicKeyBase58,
type: 'public'
});
return {

@@ -288,3 +324,9 @@ async verify({data, signature}) {

}
const publicKey = base58.decode(key.publicKeyBase58);
// browser implementation
const publicKey = _base58Decode({
decode: base58.decode,
keyMaterial: key.publicKeyBase58,
type: 'public'
});
return {

@@ -297,2 +339,29 @@ async verify({data, signature}) {

/**
* Wrap Base58 decoding operations in order to provide consistent error
* messages.
*
* @param {function} decode - the decode function to use.
* @param {string} keyMaterial - the Base58 encoded key material to decode.
* @param {string} type - a description of the keyMaterial that will be included
* in an error message (e.g. 'public', 'private').
*
* @returns {bytes} - the decoded bytes. The data structure for the bytes is
* determined by the provided decode function.
*/
function _base58Decode({decode, keyMaterial, type}) {
let bytes;
try {
bytes = decode(keyMaterial);
} catch(e) {
// do nothing
// the bs58 implementation throws, forge returns undefined
// this helper throws when no result is produced
}
if(bytes === undefined) {
throw new TypeError(`The ${type} key material must be Base58 encoded.`);
}
return bytes;
}
module.exports = Ed25519KeyPair;

4

package.json
{
"name": "crypto-ld",
"version": "3.2.0",
"version": "3.3.0",
"description": "A library for managing cryptographic keys using Linked Data.",

@@ -96,4 +96,4 @@ "homepage": "https://github.com/digitalbazaar/crypto-ld",

"coverage-report": "nyc report",
"lint": "eslint lib"
"lint": "eslint lib tests"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc