mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-04-25 13:42:32 +00:00
abandon ECD for RSA, in order to conform with go impl
This commit is contained in:
parent
9b2cb012e9
commit
9aee5bf670
22
package.json
22
package.json
@ -4,11 +4,8 @@
|
|||||||
"description": "IPFS Peer Id implementation in Node.js",
|
"description": "IPFS Peer Id implementation in Node.js",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/.bin/lab tests/*-test.js",
|
"test": "node tests/*-test.js",
|
||||||
"coverage": "./node_modules/.bin/lab -t 100 tests/*-test.js",
|
"lint": "standard"
|
||||||
"codestyle": "./node_modules/.bin/standard --format",
|
|
||||||
"lint": "jshint .",
|
|
||||||
"validate": "npm ls"
|
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"IPFS"
|
"IPFS"
|
||||||
@ -16,24 +13,25 @@
|
|||||||
"author": "David Dias <daviddias@ipfs.io>",
|
"author": "David Dias <daviddias@ipfs.io>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"pre-commit": [
|
"pre-commit": [
|
||||||
"codestyle",
|
"lint",
|
||||||
"test"
|
"test"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^4.0.0"
|
"node": "^4.2.0"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/diasdavid/node-peer-id/issues"
|
"url": "https://github.com/diasdavid/node-peer-id/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/diasdavid/node-peer-id",
|
"homepage": "https://github.com/diasdavid/node-peer-id",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"code": "^1.4.1",
|
|
||||||
"lab": "^5.13.0",
|
|
||||||
"pre-commit": "^1.1.1",
|
"pre-commit": "^1.1.1",
|
||||||
"standard": "^4.5.2"
|
"standard": "^5.3.1",
|
||||||
|
"tape": "^4.2.2",
|
||||||
|
"zuul": "^3.7.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bs58": "^2.0.1",
|
"bs58": "^3.0.0",
|
||||||
"multihashing": "^0.1.3"
|
"keypair": "^1.0.0",
|
||||||
|
"multihashing": "^0.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/index.js
10
src/index.js
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
var multihashing = require('multihashing')
|
var multihashing = require('multihashing')
|
||||||
var base58 = require('bs58')
|
var base58 = require('bs58')
|
||||||
var crypto = require('crypto')
|
var keypair = require('keypair')
|
||||||
|
|
||||||
exports = module.exports = Id
|
exports = module.exports = Id
|
||||||
|
|
||||||
@ -42,18 +42,16 @@ function Id (id, privKey, pubKey) {
|
|||||||
self.toB58String = function () {
|
self.toB58String = function () {
|
||||||
return base58.encode(self.id)
|
return base58.encode(self.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// generation
|
// generation
|
||||||
|
|
||||||
exports.create = function () {
|
exports.create = function () {
|
||||||
var ecdh = crypto.createECDH('secp256k1')
|
var pair = keypair()
|
||||||
ecdh.generateKeys()
|
|
||||||
|
|
||||||
var mhId = multihashing(ecdh.getPublicKey(), 'sha2-256')
|
var mhId = multihashing(pair.public, 'sha2-256')
|
||||||
|
|
||||||
return new Id(mhId, ecdh.getPrivateKey(), ecdh.getPublicKey())
|
return new Id(mhId, pair.private, pair.public)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.createFromHexString = function (str) {
|
exports.createFromHexString = function (str) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user