From 219aa528c84286edfeb8353b2ea50b8c243d8f76 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Tue, 2 Sep 2014 15:54:24 -0700 Subject: [PATCH] AsReceiver implied --- lib/expmt/stealthkey.js | 10 +++++----- test/stealthaddress.js | 8 ++++---- test/stealthkey.js | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/expmt/stealthkey.js b/lib/expmt/stealthkey.js index 224203f..6a2e2dc 100644 --- a/lib/expmt/stealthkey.js +++ b/lib/expmt/stealthkey.js @@ -35,7 +35,7 @@ Stealthkey.prototype.fromRandom = function() { return this; }; -Stealthkey.prototype.getSharedKeypairAsReceiver = function(senderPubkey) { +Stealthkey.prototype.getSharedKeypair = function(senderPubkey) { var sharedSecretPoint = senderPubkey.point.mul(this.scanKeypair.privkey.bn); var sharedSecretPubkey = Pubkey({point: sharedSecretPoint}); var buf = sharedSecretPubkey.toDER(true); @@ -44,15 +44,15 @@ Stealthkey.prototype.getSharedKeypairAsReceiver = function(senderPubkey) { return sharedKeypair; }; -Stealthkey.prototype.getReceivePubkeyAsReceiver = function(senderPubkey) { - var sharedKeypair = this.getSharedKeypairAsReceiver(senderPubkey); +Stealthkey.prototype.getReceivePubkey = function(senderPubkey) { + var sharedKeypair = this.getSharedKeypair(senderPubkey); var pubkey = Pubkey({point: this.payloadKeypair.pubkey.point.add(sharedKeypair.pubkey.point)}); return pubkey; }; Stealthkey.prototype.getReceiveKeypair = function(senderPubkey) { - var sharedKeypair = this.getSharedKeypairAsReceiver(senderPubkey); + var sharedKeypair = this.getSharedKeypair(senderPubkey); var privkey = Privkey({bn: this.payloadKeypair.privkey.bn.add(sharedKeypair.privkey.bn).mod(Point.getN())}); var key = Keypair({privkey: privkey}); key.privkey2pubkey(); @@ -61,7 +61,7 @@ Stealthkey.prototype.getReceiveKeypair = function(senderPubkey) { }; Stealthkey.prototype.isForMe = function(senderPubkey, myPossiblePubkeyhash) { - var pubkey = this.getReceivePubkeyAsReceiver(senderPubkey); + var pubkey = this.getReceivePubkey(senderPubkey); var pubkeybuf = pubkey.toDER(true); var pubkeyhash = Hash.sha256ripemd160(pubkeybuf); diff --git a/test/stealthaddress.js b/test/stealthaddress.js index e4962be..6fcc6e5 100644 --- a/test/stealthaddress.js +++ b/test/stealthaddress.js @@ -71,13 +71,13 @@ describe('StealthAddress', function() { (key instanceof Keypair).should.equal(true); }); - it('should return the same key as Stealthkey.prototype.getSharedKeypairAsReceiver', function() { + it('should return the same key as Stealthkey.prototype.getSharedKeypair', function() { var sa = new StealthAddress(); sa.payloadPubkey = stealthkey.payloadKeypair.pubkey; sa.scanPubkey = stealthkey.scanKeypair.pubkey; var key = sa.getSharedKeypair(senderKeypair); - var key2 = stealthkey.getSharedKeypairAsReceiver(senderKeypair.pubkey); + var key2 = stealthkey.getSharedKeypair(senderKeypair.pubkey); key.toString().should.equal(key2.toString()); }); @@ -90,9 +90,9 @@ describe('StealthAddress', function() { (pubkey instanceof Pubkey).should.equal(true); }); - it('should return the same pubkey as getReceivePubkeyAsReceiver', function() { + it('should return the same pubkey as getReceivePubkey', function() { var pubkey = StealthAddress().fromStealthkey(stealthkey).getReceivePubkey(senderKeypair); - var pubkey2 = stealthkey.getReceivePubkeyAsReceiver(senderKeypair.pubkey); + var pubkey2 = stealthkey.getReceivePubkey(senderKeypair.pubkey); pubkey2.toString().should.equal(pubkey.toString()); }); diff --git a/test/stealthkey.js b/test/stealthkey.js index 222a027..472cd75 100644 --- a/test/stealthkey.js +++ b/test/stealthkey.js @@ -62,19 +62,19 @@ describe('Stealthkey', function() { }); - describe('#getSharedKeypairAsReceiver', function() { + describe('#getSharedKeypair', function() { it('should return a key', function() { - var key = stealthkey.getSharedKeypairAsReceiver(senderKeypair.pubkey); + var key = stealthkey.getSharedKeypair(senderKeypair.pubkey); (key instanceof Keypair).should.equal(true); }); }); - describe('#getReceivePubkeyAsReceiver', function() { + describe('#getReceivePubkey', function() { it('should return a pubkey', function() { - var pubkey = stealthkey.getReceivePubkeyAsReceiver(senderKeypair.pubkey); + var pubkey = stealthkey.getReceivePubkey(senderKeypair.pubkey); (pubkey instanceof Pubkey).should.equal(true); }); @@ -87,9 +87,9 @@ describe('Stealthkey', function() { (key instanceof Keypair).should.equal(true); }); - it('should return a key with the same pubkey as getReceivePubkeyAsReceiver', function() { + it('should return a key with the same pubkey as getReceivePubkey', function() { var key = stealthkey.getReceiveKeypair(senderKeypair.pubkey); - var pubkey = stealthkey.getReceivePubkeyAsReceiver(senderKeypair.pubkey); + var pubkey = stealthkey.getReceivePubkey(senderKeypair.pubkey); key.pubkey.toString().should.equal(pubkey.toString()); });