Merge pull request #639 from bitcoinjs/stealthnames

stealth: more explicit inner variable names
This commit is contained in:
Daniel Cousens 2016-10-06 17:09:23 +11:00 committed by GitHub
commit a4afc7f9b8

View file

@ -10,27 +10,28 @@ var G = secp256k1.G
var n = secp256k1.n var n = secp256k1.n
// c = sha256: e * (d * G) // c = sha256: e * (d * G)
// cQ = (d * G) + (c * G) // vG = (d * G) + (c * G)
function stealthSend (e, Q) { function stealthSend (e, Q) {
var eQ = Q.multiply(e) // shared secret var eQ = Q.multiply(e) // shared secret
var c = bigi.fromBuffer(bitcoin.crypto.sha256(eQ.getEncoded())) var c = bigi.fromBuffer(bitcoin.crypto.sha256(eQ.getEncoded()))
var cG = G.multiply(c) var cG = G.multiply(c)
var cQ = new bitcoin.ECPair(null, Q.add(cG)) var vG = new bitcoin.ECPair(null, Q.add(cG))
return cQ return vG
} }
// c = sha256: d * (e * G) // c = sha256: d * (e * G)
// cQ = (d + c) * G // v = (d + c)
// vG = (d + c) * G
function stealthReceive (d, eG) { function stealthReceive (d, eG) {
var eQ = eG.multiply(d) // shared secret var eQ = eG.multiply(d) // shared secret
var c = bigi.fromBuffer(bitcoin.crypto.sha256(eQ.getEncoded())) var c = bigi.fromBuffer(bitcoin.crypto.sha256(eQ.getEncoded()))
var cQ = new bitcoin.ECPair(d.add(c).mod(n)) var v = new bitcoin.ECPair(d.add(c).mod(n))
return cQ return v
} }
describe('bitcoinjs-lib (crypto)', function () { describe('bitcoinjs-lib (crypto)', function () {