aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests/ringct.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests/ringct.cpp')
-rw-r--r--tests/unit_tests/ringct.cpp43
1 files changed, 29 insertions, 14 deletions
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp
index 7970fedb4..81a63b502 100644
--- a/tests/unit_tests/ringct.cpp
+++ b/tests/unit_tests/ringct.cpp
@@ -171,10 +171,12 @@ TEST(ringct, range_proofs)
sc.push_back(sctmp);
pc.push_back(pctmp);
vector<xmr_amount >amounts;
-
+ rct::keyV amount_keys;
+ key mask;
//add output 500
amounts.push_back(500);
+ amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
keyV destinations;
key Sk, Pk;
skpkGen(Sk, Pk);
@@ -183,17 +185,18 @@ TEST(ringct, range_proofs)
//add output for 12500
amounts.push_back(12500);
+ amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
skpkGen(Sk, Pk);
destinations.push_back(Pk);
//compute rct data with mixin 500
- rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, 3);
+ rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, 3);
//verify rct data
ASSERT_TRUE(verRct(s));
//decode received amount
- ASSERT_TRUE(decodeRct(s, Sk, 1));
+ ASSERT_TRUE(decodeRctFromSharedSecret(s, amount_keys[1], 1, mask));
// Ring CT with failing MG sig part should not verify!
// Since sum of inputs != outputs
@@ -204,13 +207,13 @@ TEST(ringct, range_proofs)
//compute rct data with mixin 500
- s = genRct(rct::zero(), sc, pc, destinations, amounts, 3);
+ s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, 3);
//verify rct data
ASSERT_FALSE(verRct(s));
//decode received amount
- ASSERT_TRUE(decodeRct(s, Sk, 1));
+ ASSERT_TRUE(decodeRctFromSharedSecret(s, amount_keys[1], 1, mask));
}
TEST(ringct, range_proofs_with_fee)
@@ -229,10 +232,12 @@ TEST(ringct, range_proofs_with_fee)
sc.push_back(sctmp);
pc.push_back(pctmp);
vector<xmr_amount >amounts;
-
+ keyV amount_keys;
+ key mask;
//add output 500
amounts.push_back(500);
+ amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
keyV destinations;
key Sk, Pk;
skpkGen(Sk, Pk);
@@ -241,20 +246,22 @@ TEST(ringct, range_proofs_with_fee)
//add txn fee for 1
//has no corresponding destination..
amounts.push_back(1);
+ amount_keys.push_back(hash_to_scalar(zero()));
//add output for 12500
amounts.push_back(12500);
+ amount_keys.push_back(hash_to_scalar(zero()));
skpkGen(Sk, Pk);
destinations.push_back(Pk);
//compute rct data with mixin 500
- rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, 3);
+ rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, 3);
//verify rct data
ASSERT_TRUE(verRct(s));
//decode received amount
- ASSERT_TRUE(decodeRct(s, Sk, 1));
+ ASSERT_TRUE(decodeRctFromSharedSecret(s, amount_keys[1], 1, mask));
// Ring CT with failing MG sig part should not verify!
// Since sum of inputs != outputs
@@ -265,13 +272,13 @@ TEST(ringct, range_proofs_with_fee)
//compute rct data with mixin 500
- s = genRct(rct::zero(), sc, pc, destinations, amounts, 3);
+ s = genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, 3);
//verify rct data
ASSERT_FALSE(verRct(s));
//decode received amount
- ASSERT_TRUE(decodeRct(s, Sk, 1));
+ ASSERT_TRUE(decodeRctFromSharedSecret(s, amount_keys[1], 1, mask));
}
TEST(ringct, simple)
@@ -284,6 +291,8 @@ TEST(ringct, simple)
vector<xmr_amount>inamounts;
//this keyV corresponds to destination pubkeys
keyV destinations;
+ keyV amount_keys;
+ key mask;
//add fake input 3000
//the sc is secret data
@@ -303,6 +312,7 @@ TEST(ringct, simple)
//add output 5000
outamounts.push_back(5000);
+ amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
//add the corresponding destination pubkey
key Sk, Pk;
skpkGen(Sk, Pk);
@@ -310,6 +320,7 @@ TEST(ringct, simple)
//add output 999
outamounts.push_back(999);
+ amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
//add the corresponding destination pubkey
skpkGen(Sk, Pk);
destinations.push_back(Pk);
@@ -319,13 +330,13 @@ TEST(ringct, simple)
//compute sig with mixin 2
xmr_amount txnfee = 1;
- rctSig s = genRctSimple(message, sc, pc, destinations,inamounts, outamounts, txnfee, 2);
+ rctSig s = genRctSimple(message, sc, pc, destinations,inamounts, outamounts, amount_keys, txnfee, 2);
//verify ring ct signature
ASSERT_TRUE(verRctSimple(s));
//decode received amount corresponding to output pubkey index 1
- ASSERT_TRUE(decodeRctSimple(s, Sk, 1));
+ ASSERT_TRUE(decodeRctSimpleFromSharedSecret(s, amount_keys[1], 1, mask));
}
static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amounts[], int n_outputs, const uint64_t output_amounts[], bool last_is_fee)
@@ -334,6 +345,7 @@ static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amount
ctkey sctmp, pctmp;
vector<xmr_amount >amounts;
keyV destinations;
+ keyV amount_keys;
key Sk, Pk;
for (int n = 0; n < n_inputs; ++n) {
@@ -344,12 +356,13 @@ static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amount
for (int n = 0; n < n_outputs; ++n) {
amounts.push_back(output_amounts[n]);
+ amount_keys.push_back(rct::hash_to_scalar(rct::zero()));
skpkGen(Sk, Pk);
if (n < n_outputs - 1 || !last_is_fee)
destinations.push_back(Pk);
}
- return genRct(rct::zero(), sc, pc, destinations, amounts, 3);;
+ return genRct(rct::zero(), sc, pc, destinations, amounts, amount_keys, 3);;
}
static rct::rctSig make_sample_simple_rct_sig(int n_inputs, const uint64_t input_amounts[], int n_outputs, const uint64_t output_amounts[], uint64_t fee)
@@ -358,6 +371,7 @@ static rct::rctSig make_sample_simple_rct_sig(int n_inputs, const uint64_t input
ctkey sctmp, pctmp;
vector<xmr_amount> inamounts, outamounts;
keyV destinations;
+ keyV amount_keys;
key Sk, Pk;
for (int n = 0; n < n_inputs; ++n) {
@@ -369,11 +383,12 @@ static rct::rctSig make_sample_simple_rct_sig(int n_inputs, const uint64_t input
for (int n = 0; n < n_outputs; ++n) {
outamounts.push_back(output_amounts[n]);
+ amount_keys.push_back(hash_to_scalar(zero()));
skpkGen(Sk, Pk);
destinations.push_back(Pk);
}
- return genRctSimple(rct::zero(), sc, pc, destinations, inamounts, outamounts, fee, 3);;
+ return genRctSimple(rct::zero(), sc, pc, destinations, inamounts, outamounts, amount_keys, fee, 3);;
}
static bool range_proof_test(bool expected_valid,