Skip to content

Commit df99b25

Browse files
committed
Update original Muhash PR and fix functional test
1 parent ab9fa6b commit df99b25

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/bench/crypto_hash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ BENCHMARK(SHA256D64_1024, 7400);
117117
BENCHMARK(FastRandom_32bit, 110 * 1000 * 1000);
118118
BENCHMARK(FastRandom_1bit, 440 * 1000 * 1000);
119119

120-
BENCHMARK(MuHash);
120+
BENCHMARK(MuHash, 5000);

src/crypto/muhash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ MuHash3072::MuHash3072() noexcept
286286
MuHash3072::MuHash3072(const unsigned char* key32) noexcept
287287
{
288288
unsigned char tmp[384];
289-
ChaCha20(key32, 32).Output(tmp, 384);
289+
ChaCha20(key32, 32).Keystream(tmp, 384);
290290
for (int i = 0; i < Num3072::LIMBS; ++i) {
291291
if (sizeof(Num3072::limb_type) == 4) {
292292
data.limbs[i] = ReadLE32(tmp + 4 * i);

src/test/crypto_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ BOOST_AUTO_TEST_CASE(muhash_tests)
763763
unsigned char res[384];
764764
int table[4];
765765
for (int i = 0; i < 4; ++i) {
766-
table[i] = insecure_rand_ctx.randbits(3);
766+
table[i] = g_insecure_rand_ctx.randbits(3);
767767
}
768768
for (int order = 0; order < 4; ++order) {
769769
MuHash3072 acc;
@@ -783,8 +783,8 @@ BOOST_AUTO_TEST_CASE(muhash_tests)
783783
}
784784
}
785785

786-
MuHash3072 x = FromInt(insecure_rand_ctx.randbits(4)); // x=X
787-
MuHash3072 y = FromInt(insecure_rand_ctx.randbits(4)); // x=X, y=Y
786+
MuHash3072 x = FromInt(g_insecure_rand_ctx.randbits(4)); // x=X
787+
MuHash3072 y = FromInt(g_insecure_rand_ctx.randbits(4)); // x=X, y=Y
788788
MuHash3072 z; // x=X, y=Y, z=1
789789
z *= x; // x=X, y=Y, z=X
790790
z /= y; // x=X, y=Y, z=X/Y
@@ -800,7 +800,7 @@ BOOST_AUTO_TEST_CASE(muhash_tests)
800800
acc *= FromInt(1);
801801
acc /= FromInt(2);
802802
acc.Finalize(out);
803-
uint256 x = (TruncatedSHA512Writer(SER_DISK, 0) << FLATDATA(out)).GetHash();
803+
uint256 x = (TruncatedSHA512Writer(SER_DISK, 0) << out).GetHash();
804804
BOOST_CHECK(x == uint256S("0e94c56c180f27fd6b182f091c5b007e2d6eba5ae28daa5aa92d2af8c26ea9a6"));
805805
}
806806

test/functional/rpc_blockchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def _test_gettxoutsetinfo(self):
214214
assert size > 6400
215215
assert size < 64000
216216
assert_equal(len(res['bestblock']), 64)
217-
assert_equal(len(res['hash_serialized_2']), 64)
217+
assert_equal(len(res['muhash']), 64)
218218

219219
self.log.info("Test that gettxoutsetinfo() works for blockchain with just the genesis block")
220220
b1hash = node.getblockhash(1)
@@ -227,7 +227,7 @@ def _test_gettxoutsetinfo(self):
227227
assert_equal(res2['txouts'], 0)
228228
assert_equal(res2['bogosize'], 0),
229229
assert_equal(res2['bestblock'], node.getblockhash(0))
230-
assert_equal(len(res2['hash_serialized_2']), 64)
230+
assert_equal(len(res2['muhash']), 64)
231231

232232
self.log.info("Test that gettxoutsetinfo() returns the same result after invalidate/reconsider block")
233233
node.reconsiderblock(b1hash)

0 commit comments

Comments
 (0)