add derive_subaddress_public_key function

pull/11/head
cryptochangements34 6 years ago committed by GitHub
parent 08acb35474
commit 8003f2a219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -651,6 +651,16 @@ var cnUtil = function(currencyConfig)
var s = this.derivation_to_scalar(derivation, out_index);
return bintohex(nacl.ll.ge_add(hextobin(pub), hextobin(this.ge_scalarmult_base(s))));
};
// D' = P - Hs(aR|i)G
this.derive_subaddress_public_key = function(output_key, derivation, out_index) {
if(output_key.length !== 64 || derivation.length !== 64) {
throw "Invalid input length!";
}
var scalar = this.derivation_to_scalar(derivation, out_index);
var point = this.ge_scalarmult_base(scalar);
return this.ge_sub(output_key, point);
};
this.hash_to_ec = function(key) {
if (key.length !== (KEY_SIZE * 2)) {
@ -2067,4 +2077,4 @@ var cnUtil = function(currencyConfig)
return this;
}
exports.cnUtil = cnUtil
exports.cnUtil = cnUtil

Loading…
Cancel
Save