diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-07-10 12:57:22 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-08-28 21:29:20 +0100 |
commit | a4d4d6194bf9a0826806521d72a7fec5e506a677 (patch) | |
tree | cff98fea187e5eaf765851e31e691e3f4f58f73f /tests | |
parent | serialization: add override for serializing bool (diff) | |
download | monero-a4d4d6194bf9a0826806521d72a7fec5e506a677.tar.xz |
integrate simple rct api
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core_tests/rct.cpp | 5 | ||||
-rw-r--r-- | tests/unit_tests/ringct.cpp | 64 | ||||
-rw-r--r-- | tests/unit_tests/serialization.cpp | 3 |
3 files changed, 65 insertions, 7 deletions
diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp index f16045ef6..ef5f72fb0 100644 --- a/tests/core_tests/rct.cpp +++ b/tests/core_tests/rct.cpp @@ -127,7 +127,10 @@ bool gen_rct_tx_validation_base::generate_with(std::vector<test_event_entry>& ev cryptonote::keypair in_ephemeral; crypto::key_image ki; cryptonote::generate_key_image_helper(miner_accounts[n].get_keys(), tx_pub_key, o, in_ephemeral, ki); - rct::decodeRct(rct_txes[n].rct_signatures, rct::sk2rct(in_ephemeral.sec), o, rct_tx_masks[o+n*4]); + if (rct_txes[n].rct_signatures.simple) + rct::decodeRctSimple(rct_txes[n].rct_signatures, rct::sk2rct(in_ephemeral.sec), o, rct_tx_masks[o+n*4]); + else + rct::decodeRct(rct_txes[n].rct_signatures, rct::sk2rct(in_ephemeral.sec), o, rct_tx_masks[o+n*4]); } CHECK_AND_ASSERT_MES(generator.construct_block_manually(blk_txes[n], blk_last, miner_account, 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) { |