PIVX Core  5.6.99
P2P Digital Currency
pedersen_hash_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016-2020 The ZCash developers
2 // Copyright (c) 2020-2021 The PIVX Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "test/test_pivx.h"
7 
8 #include "arith_uint256.h"
9 #include "uint256.h"
10 #include "utilstrencodings.h"
11 
12 #include <boost/test/unit_test.hpp>
13 #include <librustzcash.h>
14 
15 BOOST_FIXTURE_TEST_SUITE(pedersen_hash_tests, BasicTestingSetup)
16 
17 BOOST_AUTO_TEST_CASE(pedersen_hash_testvectors)
18 {
19  // Good scenario check
20  const uint256 a = uint256S("87a086ae7d2252d58729b30263fb7b66308bf94ef59a76c9c86e7ea016536505");
21  const uint256 b = uint256S("a75b84a125b2353da7e8d96ee2a15efe4de23df9601b9d9564ba59de57130406");
22  uint256 result;
23 
24  librustzcash_merkle_hash(25, a.begin(), b.begin(), result.begin());
25 
26  uint256 expected_result = uint256S("5bf43b5736c19b714d1f462c9d22ba3492c36e3d9bbd7ca24d94b440550aa561");
27 
28  BOOST_CHECK(result == expected_result);
29 
30  // Simple bad scenario check
32  result.SetNull();
33  librustzcash_merkle_hash(25, c.begin(), b.begin(), result.begin());
34  BOOST_CHECK(result != expected_result);
35 }
36 
arith_uint256 UintToArith256(const uint256 &a)
uint256 ArithToUint256(const arith_uint256 &a)
const arith_uint256 ARITH_UINT256_ONE
void SetNull()
Definition: uint256.h:44
unsigned char * begin()
Definition: uint256.h:63
256-bit opaque blob.
Definition: uint256.h:138
BOOST_AUTO_TEST_SUITE_END()
void librustzcash_merkle_hash(size_t depth, const unsigned char *a, const unsigned char *b, unsigned char *result)
Computes a merkle tree hash for a given depth.
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_CHECK(expr)
Definition: object.cpp:17
BOOST_AUTO_TEST_CASE(pedersen_hash_testvectors)
Basic testing setup.
Definition: test_pivx.h:51
uint256 uint256S(const char *str)
Definition: uint256.h:157