aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/ringct.cpp64
-rw-r--r--tests/unit_tests/serialization.cpp3
2 files changed, 61 insertions, 6 deletions
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp
index 4b494edba..a7011bb2b 100644
--- a/tests/unit_tests/ringct.cpp
+++ b/tests/unit_tests/ringct.cpp
@@ -187,7 +187,7 @@ TEST(ringct, range_proofs)
destinations.push_back(Pk);
//compute rct data with mixin 500
- rctSig s = genRct(sc, pc, destinations, amounts, rct::zero(), 3);
+ rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, 3);
//verify rct data
ASSERT_TRUE(verRct(s));
@@ -204,7 +204,7 @@ TEST(ringct, range_proofs)
//compute rct data with mixin 500
- s = genRct(sc, pc, destinations, amounts, rct::zero(), 3);
+ s = genRct(rct::zero(), sc, pc, destinations, amounts, 3);
//verify rct data
ASSERT_FALSE(verRct(s));
@@ -248,7 +248,7 @@ TEST(ringct, range_proofs_with_fee)
destinations.push_back(Pk);
//compute rct data with mixin 500
- rctSig s = genRct(sc, pc, destinations, amounts, rct::zero(), 3);
+ rctSig s = genRct(rct::zero(), sc, pc, destinations, amounts, 3);
//verify rct data
ASSERT_TRUE(verRct(s));
@@ -265,7 +265,7 @@ TEST(ringct, range_proofs_with_fee)
//compute rct data with mixin 500
- s = genRct(sc, pc, destinations, amounts, rct::zero(), 3);
+ s = genRct(rct::zero(), sc, pc, destinations, amounts, 3);
//verify rct data
ASSERT_FALSE(verRct(s));
@@ -274,6 +274,60 @@ TEST(ringct, range_proofs_with_fee)
ASSERT_TRUE(decodeRct(s, Sk, 1));
}
+TEST(ringct, simple)
+{
+ ctkeyV sc, pc;
+ ctkey sctmp, pctmp;
+ //this vector corresponds to output amounts
+ vector<xmr_amount>outamounts;
+ //this vector corresponds to input amounts
+ vector<xmr_amount>inamounts;
+ //this keyV corresponds to destination pubkeys
+ keyV destinations;
+
+ //add fake input 3000
+ //the sc is secret data
+ //pc is public data
+ tie(sctmp, pctmp) = ctskpkGen(3000);
+ sc.push_back(sctmp);
+ pc.push_back(pctmp);
+ inamounts.push_back(3000);
+
+ //add fake input 3000
+ //the sc is secret data
+ //pc is public data
+ tie(sctmp, pctmp) = ctskpkGen(3000);
+ sc.push_back(sctmp);
+ pc.push_back(pctmp);
+ inamounts.push_back(3000);
+
+ //add output 5000
+ outamounts.push_back(5000);
+ //add the corresponding destination pubkey
+ key Sk, Pk;
+ skpkGen(Sk, Pk);
+ destinations.push_back(Pk);
+
+ //add output 999
+ outamounts.push_back(999);
+ //add the corresponding destination pubkey
+ skpkGen(Sk, Pk);
+ destinations.push_back(Pk);
+
+ key message = skGen(); //real message later (hash of txn..)
+
+ //compute sig with mixin 2
+ xmr_amount txnfee = 1;
+
+ rctSig s = genRctSimple(message, sc, pc, destinations,inamounts, outamounts, 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));
+}
+
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)
{
ctkeyV sc, pc;
@@ -295,7 +349,7 @@ static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amount
destinations.push_back(Pk);
}
- return genRct(sc, pc, destinations, amounts, rct::zero(), 3);;
+ return genRct(rct::zero(), sc, pc, destinations, amounts, 3);;
}
static bool range_proof_test(bool expected_valid,
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp
index 01dff3e99..88e67bd73 100644
--- a/tests/unit_tests/serialization.cpp
+++ b/tests/unit_tests/serialization.cpp
@@ -565,7 +565,7 @@ TEST(Serialization, serializes_ringct_types)
rct::skpkGen(Sk, Pk);
destinations.push_back(Pk);
//compute rct data with mixin 500
- s0 = rct::genRct(sc, pc, destinations, amounts, rct::zero(), 3);
+ s0 = rct::genRct(rct::zero(), sc, pc, destinations, amounts, 3);
mg0 = s0.MG;
ASSERT_TRUE(serialization::dump_binary(mg0, blob));
@@ -588,6 +588,7 @@ TEST(Serialization, serializes_ringct_types)
ASSERT_TRUE(serialization::dump_binary(s0, blob));
ASSERT_TRUE(serialization::parse_binary(blob, s1));
+ ASSERT_TRUE(s0.simple == s1.simple);
ASSERT_TRUE(s0.rangeSigs.size() == s1.rangeSigs.size());
for (size_t n = 0; n < s0.rangeSigs.size(); ++n)
{