started slight refactoring of cn_utilts.js

pull/5/head
moneroexamples 7 years ago
parent dc89835ad8
commit 912068e6c1

@ -745,7 +745,19 @@ var cnUtil = (function(initConfig) {
this.generate_key_image_helper_rct = function(keys, tx_pub_key, out_index, enc_mask) {
var recv_derivation = this.generate_key_derivation(tx_pub_key, keys.view.sec);
if (!recv_derivation) throw "Failed to generate key image";
var mask = enc_mask ? sc_sub(enc_mask, hash_to_scalar(derivation_to_scalar(recv_derivation, out_index))) : I; //decode mask, or d2s(1) if no mask
var mask;
if (enc_mask === I)
{
// this is for ringct coinbase txs (rct type 0). they are ringct tx that have identity mask
mask = enc_mask;
}
else
{
// for other ringct types or for non-ringct txs to this.
mask = enc_mask ? sc_sub(enc_mask, hash_to_scalar(derivation_to_scalar(recv_derivation, out_index))) : I; //decode mask, or d2s(1) if no mask
}
var mask = enc_mask; //decode mask, or d2s(1) if no mask
var ephemeral_pub = this.derive_public_key(recv_derivation, out_index, keys.spend.pub);
if (!ephemeral_pub) throw "Failed to generate key image";
var ephemeral_sec = this.derive_secret_key(recv_derivation, out_index, keys.spend.sec);
@ -1700,9 +1712,13 @@ var cnUtil = (function(initConfig) {
a: in_contexts[i].mask
});
inAmounts.push(tx.vin[i].amount);
if (in_contexts[i].mask !== I) {//if input is rct (has a valid mask), 0 out amount
//if (in_contexts[i].mask !== I) {//if input is rct (has a valid mask), 0 out amount
// coiinbase txs also have mask === I, so I removed this if statmemt here.
tx.vin[i].amount = "0";
}
//}
mixRing[i] = [];
for (j = 0; j < sources[i].outputs.length; j++) {
mixRing[i].push({
@ -1826,6 +1842,7 @@ var cnUtil = (function(initConfig) {
if (outputs[i].rct) {
src.mask = outputs[i].rct.slice(64,128); //encrypted
// src.mask = null;
} else {
src.mask = null; //will be set by generate_key_image_helper_rct
}

@ -822,6 +822,7 @@ CurrentBlockchainStatus::construct_output_rct_field(
// i think for ringct coinbase txs, mask is identity mask
// as suggested by this code:
// https://github.com/monero-project/monero/blob/eacf2124b6822d088199179b18d4587404408e0f/src/wallet/wallet2.cpp#L893
// https://github.com/monero-project/monero/blob/master/src/blockchain_db/blockchain_db.cpp#L100
rtc_mask = pod_to_hex(rct::identity());
}

@ -500,13 +500,20 @@ YourMoneroRequests::get_unspent_outs(const shared_ptr< Session > session, const
// string rtc_outpk = pod_to_hex(od.commitment);
// string rtc_mask = pod_to_hex(rct::identity());
// string rtc_amount('0', 64);
// string rtc_amount(64, '0');
string rtc_outpk = pod_to_hex(od.commitment);
string rtc_mask = pod_to_hex(rct::identity());
string rtc_amount = std::to_string(out.amount);
cout << rtc_amount << endl;
string rtc_mask = pod_to_hex(rct::identity());
string rtc_amount(64, '0');
cout << "od.commitment: " << pod_to_hex(od.commitment) << endl;
cout << "rct::commit(out.amount, od.commitment): " << pod_to_hex(rct::commit(out.amount, od.commitment)) << endl;
cout << "rct::commit(out.amount, rct::identity()): " << pod_to_hex(rct::commit(out.amount, rct::identity())) << endl;
cout << "pod_to_hex(rct::zeroCommit(out.amount)): " << pod_to_hex(rct::zeroCommit(out.amount)) << endl;
//cout << rtc_outpk << endl;
//cout << rtc_mask << endl;
//cout << rtc_amount << endl;
cout << endl;
// string rtc_outpk = pod_to_hex(od.commitment);

Loading…
Cancel
Save