make receivePubkey compatible with dark wallet
I had been using this formula for the receiveKeypair: scanKeypair + payloadKeypair + sharedKeypair However, Dark Wallet uses this formula: payloadKeypair + sharedKeypair It is not actually necessary to add the scanKeypair in order to have all the features of stealth addresses, at least as far as I can tell. So in order to bring my implementation closer to Dark Wallet's, I have removed the scanKeypair from this calculation.
This commit is contained in:
parent
7647663a5e
commit
cfd509f859
|
@ -65,7 +65,7 @@ StealthAddress.prototype.getSharedKeypair = function(senderKeypair) {
|
|||
|
||||
StealthAddress.prototype.getReceivePubkey = function(senderKeypair) {
|
||||
var sharedKeypair = this.getSharedKeypair(senderKeypair);
|
||||
var pubkey = Pubkey(this.scanPubkey.point.add(sharedKeypair.pubkey.point).add(this.payloadPubkey.point));
|
||||
var pubkey = Pubkey(this.payloadPubkey.point.add(sharedKeypair.pubkey.point));
|
||||
|
||||
return pubkey;
|
||||
};
|
||||
|
|
|
@ -46,14 +46,14 @@ Stealthkey.prototype.getSharedKeypair = function(senderPubkey) {
|
|||
|
||||
Stealthkey.prototype.getReceivePubkey = function(senderPubkey) {
|
||||
var sharedKeypair = this.getSharedKeypair(senderPubkey);
|
||||
var pubkey = Pubkey({point: this.scanKeypair.pubkey.point.add(sharedKeypair.pubkey.point).add(this.payloadKeypair.pubkey.point)});
|
||||
var pubkey = Pubkey({point: this.payloadKeypair.pubkey.point.add(sharedKeypair.pubkey.point)});
|
||||
|
||||
return pubkey;
|
||||
};
|
||||
|
||||
Stealthkey.prototype.getReceiveKeypair = function(senderPubkey) {
|
||||
var sharedKeypair = this.getSharedKeypair(senderPubkey);
|
||||
var privkey = Privkey({bn: this.scanKeypair.privkey.bn.add(sharedKeypair.privkey.bn).add(this.payloadKeypair.privkey.bn).mod(Point.getN())});
|
||||
var privkey = Privkey({bn: this.payloadKeypair.privkey.bn.add(sharedKeypair.privkey.bn).mod(Point.getN())});
|
||||
var key = Keypair({privkey: privkey});
|
||||
key.privkey2pubkey();
|
||||
|
||||
|
|
|
@ -103,12 +103,12 @@ describe('Stealthkey', function() {
|
|||
describe('#isForMe', function() {
|
||||
|
||||
it('should return true if it (the transaction or message) is for me', function() {
|
||||
var pubkeyhash = new Buffer('0db7f06cffb913322e211e8b0688efe8ff52aa8d', 'hex');
|
||||
var pubkeyhash = new Buffer('3cb64fa6ee9b3e8754e3e2bd033bf61048604a99', 'hex');
|
||||
stealthkey.isForMe(senderKeypair.pubkey, pubkeyhash).should.equal(true);
|
||||
});
|
||||
|
||||
it('should return false if it (the transaction or message) is not for me', function() {
|
||||
var pubkeyhash = new Buffer('ffb7f06cffb913322e211e8b0688efe8ff52aa8d', 'hex');
|
||||
var pubkeyhash = new Buffer('00b64fa6ee9b3e8754e3e2bd033bf61048604a99', 'hex');
|
||||
stealthkey.isForMe(senderKeypair.pubkey, pubkeyhash).should.equal(false);
|
||||
});
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('StealthMessage', function() {
|
|||
var payloadKeypair = KDF.buf2keypair(new Buffer('key1'));
|
||||
var scanKeypair = KDF.buf2keypair(new Buffer('key2'));
|
||||
var fromKeypair = KDF.buf2keypair(new Buffer('key3'));
|
||||
var enchex = '3867dce7be22e8551512b25f329b51fd5fe8ecfe0381c7831a20c7c9ec88dcf092ea3683261798ccda991ed65a3a54a036d8125dec0381c7831a20c7c9ec88dcf092ea3683261798ccda991ed65a3a54a036d8125dec9f86d081884c7d659a2feaa0c55ad015aca97de5af3a34a0f47eee0a1f7774dcb759187555003282bd23b047bceb5b2f2c1ee35b8f0be1fda7a41424f6cc8030559c8c32ea8cc812860f4c8123f1417a';
|
||||
var enchex = 'f557994f16d0d628fa4fdb4ab3d7e0bc5f2754f20381c7831a20c7c9ec88dcf092ea3683261798ccda991ed65a3a54a036d8125dec0381c7831a20c7c9ec88dcf092ea3683261798ccda991ed65a3a54a036d8125dec9f86d081884c7d659a2feaa0c55ad01560ba2904d3bc8395b6c4a6f87648edb33db6a22170e5e26f340c7ba943169210234cd6a753ad13919b0ab7d678b47b5e7d63e452382de2c2590fb57ef048f7b3';
|
||||
var encbuf = new Buffer(enchex, 'hex');
|
||||
var ivbuf = Hash.sha256(new Buffer('test')).slice(0, 128 / 8);
|
||||
var sk = Stealthkey().set({payloadKeypair: payloadKeypair, scanKeypair: scanKeypair});
|
||||
|
|
Loading…
Reference in New Issue