|
@ -35,7 +35,7 @@ Stealthkey.prototype.fromRandom = function() { |
|
|
return this; |
|
|
return this; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Stealthkey.prototype.getSharedKeypairAsReceiver = function(senderPubkey) { |
|
|
Stealthkey.prototype.getSharedKeypair = function(senderPubkey) { |
|
|
var sharedSecretPoint = senderPubkey.point.mul(this.scanKeypair.privkey.bn); |
|
|
var sharedSecretPoint = senderPubkey.point.mul(this.scanKeypair.privkey.bn); |
|
|
var sharedSecretPubkey = Pubkey({point: sharedSecretPoint}); |
|
|
var sharedSecretPubkey = Pubkey({point: sharedSecretPoint}); |
|
|
var buf = sharedSecretPubkey.toDER(true); |
|
|
var buf = sharedSecretPubkey.toDER(true); |
|
@ -44,15 +44,15 @@ Stealthkey.prototype.getSharedKeypairAsReceiver = function(senderPubkey) { |
|
|
return sharedKeypair; |
|
|
return sharedKeypair; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Stealthkey.prototype.getReceivePubkeyAsReceiver = function(senderPubkey) { |
|
|
Stealthkey.prototype.getReceivePubkey = function(senderPubkey) { |
|
|
var sharedKeypair = this.getSharedKeypairAsReceiver(senderPubkey); |
|
|
var sharedKeypair = this.getSharedKeypair(senderPubkey); |
|
|
var pubkey = Pubkey({point: this.payloadKeypair.pubkey.point.add(sharedKeypair.pubkey.point)}); |
|
|
var pubkey = Pubkey({point: this.payloadKeypair.pubkey.point.add(sharedKeypair.pubkey.point)}); |
|
|
|
|
|
|
|
|
return pubkey; |
|
|
return pubkey; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Stealthkey.prototype.getReceiveKeypair = function(senderPubkey) { |
|
|
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 privkey = Privkey({bn: this.payloadKeypair.privkey.bn.add(sharedKeypair.privkey.bn).mod(Point.getN())}); |
|
|
var key = Keypair({privkey: privkey}); |
|
|
var key = Keypair({privkey: privkey}); |
|
|
key.privkey2pubkey(); |
|
|
key.privkey2pubkey(); |
|
@ -61,7 +61,7 @@ Stealthkey.prototype.getReceiveKeypair = function(senderPubkey) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Stealthkey.prototype.isForMe = function(senderPubkey, myPossiblePubkeyhash) { |
|
|
Stealthkey.prototype.isForMe = function(senderPubkey, myPossiblePubkeyhash) { |
|
|
var pubkey = this.getReceivePubkeyAsReceiver(senderPubkey); |
|
|
var pubkey = this.getReceivePubkey(senderPubkey); |
|
|
var pubkeybuf = pubkey.toDER(true); |
|
|
var pubkeybuf = pubkey.toDER(true); |
|
|
var pubkeyhash = Hash.sha256ripemd160(pubkeybuf); |
|
|
var pubkeyhash = Hash.sha256ripemd160(pubkeybuf); |
|
|
|
|
|
|
|
|