initial work replacing symmetric shared secret with ECIES
This commit is contained in:
parent
a535d93b6f
commit
31d601b2a6
4 changed files with 55 additions and 23 deletions
|
|
@ -20,13 +20,25 @@ function PrivateKey(opts) {
|
|||
|
||||
PrivateKey.prototype.getId = function() {
|
||||
if (!this.id) {
|
||||
var path = Structure.IdFullBranch;
|
||||
var idhk = this.bip.derive(path);
|
||||
this.id= idhk.eckey.public.toString('hex');
|
||||
this.cacheId();
|
||||
}
|
||||
return this.id;
|
||||
};
|
||||
|
||||
PrivateKey.prototype.getIdPriv = function() {
|
||||
if (!this.idpriv) {
|
||||
this.cacheId();
|
||||
}
|
||||
return this.idpriv;
|
||||
};
|
||||
|
||||
PrivateKey.prototype.cacheId = function() {
|
||||
var path = Structure.IdFullBranch;
|
||||
var idhk = this.bip.derive(path);
|
||||
this.id = idhk.eckey.public.toString('hex');
|
||||
this.idpriv = idhk.eckey.private.toString('hex');
|
||||
};
|
||||
|
||||
PrivateKey.prototype.deriveBIP45Branch = function() {
|
||||
if (!this.bip45Branch) {
|
||||
this.bip45Branch = this.bip.derive(Structure.BIP45_PUBLIC_PREFIX);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function Wallet(opts) {
|
|||
|
||||
this.id = opts.id || Wallet.getRandomId();
|
||||
this.name = opts.name;
|
||||
this.netKey = opts.netKey || SecureRandom.getRandomBuffer(8).toString('base64');
|
||||
//this.netKey = opts.netKey || SecureRandom.getRandomBuffer(8).toString('base64');
|
||||
|
||||
// Renew token every 24hs
|
||||
if (opts.tokenTime && new Date().getTime() - opts.tokenTime < 86400000) {
|
||||
|
|
@ -216,7 +216,7 @@ Wallet.prototype._optsToObj = function() {
|
|||
requiredCopayers: this.requiredCopayers,
|
||||
totalCopayers: this.totalCopayers,
|
||||
name: this.name,
|
||||
netKey: this.netKey,
|
||||
//netKey: this.netKey,
|
||||
version: this.version,
|
||||
};
|
||||
|
||||
|
|
@ -240,21 +240,21 @@ Wallet.prototype.getMyCopayerId = function() {
|
|||
|
||||
|
||||
Wallet.prototype.getSecret = function() {
|
||||
var i = new Buffer(this.getMyCopayerId(), 'hex');
|
||||
var k = new Buffer(this.netKey, 'base64');
|
||||
var b = Buffer.concat([i, k]);
|
||||
var str = Base58Check.encode(b);
|
||||
var pubkeybuf = new Buffer(this.getMyCopayerId(), 'hex');
|
||||
//var k = new Buffer(this.netKey, 'base64');
|
||||
//var b = Buffer.concat([i, k]);
|
||||
var str = Base58Check.encode(pubkeybuf);
|
||||
return str;
|
||||
};
|
||||
|
||||
|
||||
Wallet.decodeSecret = function(secretB) {
|
||||
var secret = Base58Check.decode(secretB);
|
||||
var netKeyBuf = secret.slice(-8);
|
||||
//var netKeyBuf = secret.slice(-8);
|
||||
var pubKeyBuf = secret.slice(0, 33);
|
||||
return {
|
||||
pubKey: pubKeyBuf.toString('hex'),
|
||||
netKey: netKeyBuf.toString('base64'),
|
||||
pubKey: pubKeyBuf.toString('hex')//,
|
||||
//netKey: netKeyBuf.toString('base64'),
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -280,8 +280,8 @@ Wallet.prototype.netStart = function() {
|
|||
var startOpts = {
|
||||
copayerId: myId,
|
||||
token: self.token,
|
||||
maxPeers: self.totalCopayers,
|
||||
netKey: this.netKey,
|
||||
maxPeers: self.totalCopayers//,
|
||||
//netKey: this.netKey,
|
||||
};
|
||||
|
||||
if (this.publicKeyRing.isComplete()) {
|
||||
|
|
|
|||
|
|
@ -220,7 +220,8 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphras
|
|||
this.log('\t### PrivateKey Initialized');
|
||||
var opts = {
|
||||
copayerId: privateKey.getId(),
|
||||
netKey: s.netKey,
|
||||
//netKey: s.netKey,
|
||||
privkey: privateKey.getIdPriv()
|
||||
};
|
||||
self.network.cleanUp();
|
||||
self.network.start(opts, function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue