Comparing version 3.5.3 to 3.6.0
# crypto-ld ChangeLog | ||
## 3.6.0 - 2019-08-06 | ||
### Added | ||
- Add `LDKeyPair.fromFingerprint()` to create an Ed25519KeyPair instance | ||
from a fingerprint (for use with `did:key` method code). | ||
## 3.5.3 - 2019-07-16 | ||
@@ -4,0 +10,0 @@ |
@@ -7,2 +7,3 @@ /*! | ||
const forge = require('node-forge'); | ||
const {util: {binary: {base58}}} = forge; | ||
@@ -118,3 +119,28 @@ class LDKeyPair { | ||
} | ||
/** | ||
* Creates an instance of LDKeyPair from a key fingerprint. | ||
* Note: Only key types that use their full public key in the fingerprint | ||
* are supported (so, currently, only 'ed25519'). | ||
* | ||
* @param {string} fingerprint | ||
* @returns {LDKeyPair} | ||
* @throws Unsupported Fingerprint Type. | ||
*/ | ||
static fromFingerprint({fingerprint}) { | ||
// skip leading `z` that indicates base58 encoding | ||
const buffer = base58.decode(fingerprint.substr(1)); | ||
// buffer is: 0xed 0x01 <public key bytes> | ||
if(buffer[0] === 0xed && buffer[1] === 0x01) { | ||
const Ed25519KeyPair = require('./Ed25519KeyPair'); | ||
return new Ed25519KeyPair({ | ||
publicKeyBase58: base58.encode(buffer.slice(2)) | ||
}); | ||
} | ||
throw new Error(`Unsupported Fingerprint Type: ${fingerprint}`); | ||
} | ||
/** | ||
* Generates a | ||
@@ -121,0 +147,0 @@ * [pdkdf2]{@link https://en.wikipedia.org/wiki/PBKDF2} key. |
{ | ||
"name": "crypto-ld", | ||
"version": "3.5.3", | ||
"version": "3.6.0", | ||
"description": "A library for managing cryptographic keys using Linked Data.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/digitalbazaar/crypto-ld", |
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
47412
1149