mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-04-25 06:22:24 +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",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "./node_modules/.bin/lab tests/*-test.js",
|
||||
"coverage": "./node_modules/.bin/lab -t 100 tests/*-test.js",
|
||||
"codestyle": "./node_modules/.bin/standard --format",
|
||||
"lint": "jshint .",
|
||||
"validate": "npm ls"
|
||||
"test": "node tests/*-test.js",
|
||||
"lint": "standard"
|
||||
},
|
||||
"keywords": [
|
||||
"IPFS"
|
||||
@ -16,24 +13,25 @@
|
||||
"author": "David Dias <daviddias@ipfs.io>",
|
||||
"license": "MIT",
|
||||
"pre-commit": [
|
||||
"codestyle",
|
||||
"lint",
|
||||
"test"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^4.0.0"
|
||||
"node": "^4.2.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/diasdavid/node-peer-id/issues"
|
||||
},
|
||||
"homepage": "https://github.com/diasdavid/node-peer-id",
|
||||
"devDependencies": {
|
||||
"code": "^1.4.1",
|
||||
"lab": "^5.13.0",
|
||||
"pre-commit": "^1.1.1",
|
||||
"standard": "^4.5.2"
|
||||
"standard": "^5.3.1",
|
||||
"tape": "^4.2.2",
|
||||
"zuul": "^3.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"bs58": "^2.0.1",
|
||||
"multihashing": "^0.1.3"
|
||||
"bs58": "^3.0.0",
|
||||
"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 base58 = require('bs58')
|
||||
var crypto = require('crypto')
|
||||
var keypair = require('keypair')
|
||||
|
||||
exports = module.exports = Id
|
||||
|
||||
@ -42,18 +42,16 @@ function Id (id, privKey, pubKey) {
|
||||
self.toB58String = function () {
|
||||
return base58.encode(self.id)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// generation
|
||||
|
||||
exports.create = function () {
|
||||
var ecdh = crypto.createECDH('secp256k1')
|
||||
ecdh.generateKeys()
|
||||
var pair = keypair()
|
||||
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user