From 7ec8c5d30925eb6ddaf24ceac00ccf10e865b589 Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Fri, 13 Sep 2019 00:42:32 -0600 Subject: [PATCH 1/3] precompute empty merkle roots --- src/zcash/IncrementalMerkleTree.cpp | 790 ++++++++++++++++++++++++++++ src/zcash/IncrementalMerkleTree.hpp | 13 +- 2 files changed, 795 insertions(+), 8 deletions(-) diff --git a/src/zcash/IncrementalMerkleTree.cpp b/src/zcash/IncrementalMerkleTree.cpp index f8d5fad61..5a7d71537 100644 --- a/src/zcash/IncrementalMerkleTree.cpp +++ b/src/zcash/IncrementalMerkleTree.cpp @@ -35,6 +35,392 @@ PedersenHash PedersenHash::uncommitted() { return res; } +static const std::array pedersen_empty_roots = { + uint256(std::vector{ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }), + uint256(std::vector{ + 0x81, 0x7d, 0xe3, 0x6a, 0xb2, 0xd5, 0x7f, 0xeb, + 0x07, 0x76, 0x34, 0xbc, 0xa7, 0x78, 0x19, 0xc8, + 0xe0, 0xbd, 0x29, 0x8c, 0x04, 0xf6, 0xfe, 0xd0, + 0xe6, 0xa8, 0x3c, 0xc1, 0x35, 0x6c, 0xa1, 0x55, + }), + uint256(std::vector{ + 0xff, 0xe9, 0xfc, 0x03, 0xf1, 0x8b, 0x17, 0x6c, + 0x99, 0x88, 0x06, 0x43, 0x9f, 0xf0, 0xbb, 0x8a, + 0xd1, 0x93, 0xaf, 0xdb, 0x27, 0xb2, 0xcc, 0xbc, + 0x88, 0x85, 0x69, 0x16, 0xdd, 0x80, 0x4e, 0x34, + }), + uint256(std::vector{ + 0xd8, 0x28, 0x33, 0x86, 0xef, 0x2e, 0xf0, 0x7e, + 0xbd, 0xbb, 0x43, 0x83, 0xc1, 0x2a, 0x73, 0x9a, + 0x95, 0x3a, 0x4d, 0x6e, 0x0d, 0x6f, 0xb1, 0x13, + 0x9a, 0x40, 0x36, 0xd6, 0x93, 0xbf, 0xbb, 0x6c, + }), + uint256(std::vector{ + 0xe1, 0x10, 0xde, 0x65, 0xc9, 0x07, 0xb9, 0xde, + 0xa4, 0xae, 0x0b, 0xd8, 0x3a, 0x4b, 0x0a, 0x51, + 0xbe, 0xa1, 0x75, 0x64, 0x6a, 0x64, 0xc1, 0x2b, + 0x4c, 0x9f, 0x93, 0x1b, 0x2c, 0xb3, 0x1b, 0x49, + }), + uint256(std::vector{ + 0x91, 0x2d, 0x82, 0xb2, 0xc2, 0xbc, 0xa2, 0x31, + 0xf7, 0x1e, 0xfc, 0xf6, 0x17, 0x37, 0xfb, 0xf0, + 0xa0, 0x8b, 0xef, 0xa0, 0x41, 0x62, 0x15, 0xae, + 0xef, 0x53, 0xe8, 0xbb, 0x6d, 0x23, 0x39, 0x0a, + }), + uint256(std::vector{ + 0x8a, 0xc9, 0xcf, 0x9c, 0x39, 0x1e, 0x3f, 0xd4, + 0x28, 0x91, 0xd2, 0x72, 0x38, 0xa8, 0x1a, 0x8a, + 0x5c, 0x1d, 0x3a, 0x72, 0xb1, 0xbc, 0xbe, 0xa8, + 0xcf, 0x44, 0xa5, 0x8c, 0xe7, 0x38, 0x96, 0x13, + }), + uint256(std::vector{ + 0xd6, 0xc6, 0x39, 0xac, 0x24, 0xb4, 0x6b, 0xd1, + 0x93, 0x41, 0xc9, 0x1b, 0x13, 0xfd, 0xca, 0xb3, + 0x15, 0x81, 0xdd, 0xaf, 0x7f, 0x14, 0x11, 0x33, + 0x6a, 0x27, 0x1f, 0x3d, 0x0a, 0xa5, 0x28, 0x13, + }), + uint256(std::vector{ + 0x7b, 0x99, 0xab, 0xdc, 0x37, 0x30, 0x99, 0x1c, + 0xc9, 0x27, 0x47, 0x27, 0xd7, 0xd8, 0x2d, 0x28, + 0xcb, 0x79, 0x4e, 0xdb, 0xc7, 0x03, 0x4b, 0x4f, + 0x00, 0x53, 0xff, 0x7c, 0x4b, 0x68, 0x04, 0x44, + }), + uint256(std::vector{ + 0x43, 0xff, 0x54, 0x57, 0xf1, 0x3b, 0x92, 0x6b, + 0x61, 0xdf, 0x55, 0x2d, 0x4e, 0x40, 0x2e, 0xe6, + 0xdc, 0x14, 0x63, 0xf9, 0x9a, 0x53, 0x5f, 0x9a, + 0x71, 0x34, 0x39, 0x26, 0x4d, 0x5b, 0x61, 0x6b, + }), + uint256(std::vector{ + 0xba, 0x49, 0xb6, 0x59, 0xfb, 0xd0, 0xb7, 0x33, + 0x42, 0x11, 0xea, 0x6a, 0x9d, 0x9d, 0xf1, 0x85, + 0xc7, 0x57, 0xe7, 0x0a, 0xa8, 0x1d, 0xa5, 0x62, + 0xfb, 0x91, 0x2b, 0x84, 0xf4, 0x9b, 0xce, 0x72, + }), + uint256(std::vector{ + 0x47, 0x77, 0xc8, 0x77, 0x6a, 0x3b, 0x1e, 0x69, + 0xb7, 0x3a, 0x62, 0xfa, 0x70, 0x1f, 0xa4, 0xf7, + 0xa6, 0x28, 0x2d, 0x9a, 0xee, 0x2c, 0x7a, 0x6b, + 0x82, 0xe7, 0x93, 0x7d, 0x70, 0x81, 0xc2, 0x3c, + }), + uint256(std::vector{ + 0xec, 0x67, 0x71, 0x14, 0xc2, 0x72, 0x06, 0xf5, + 0xde, 0xbc, 0x1c, 0x1e, 0xd6, 0x6f, 0x95, 0xe2, + 0xb1, 0x88, 0x5d, 0xa5, 0xb7, 0xbe, 0x3d, 0x73, + 0x6b, 0x1d, 0xe9, 0x85, 0x79, 0x47, 0x30, 0x48, + }), + uint256(std::vector{ + 0x1b, 0x77, 0xda, 0xc4, 0xd2, 0x4f, 0xb7, 0x25, + 0x8c, 0x3c, 0x52, 0x87, 0x04, 0xc5, 0x94, 0x30, + 0xb6, 0x30, 0x71, 0x8b, 0xec, 0x48, 0x64, 0x21, + 0x83, 0x70, 0x21, 0xcf, 0x75, 0xda, 0xb6, 0x51, + }), + uint256(std::vector{ + 0xbd, 0x74, 0xb2, 0x5a, 0xac, 0xb9, 0x23, 0x78, + 0xa8, 0x71, 0xbf, 0x27, 0xd2, 0x25, 0xcf, 0xc2, + 0x6b, 0xac, 0xa3, 0x44, 0xa1, 0xea, 0x35, 0xfd, + 0xd9, 0x45, 0x10, 0xf3, 0xd1, 0x57, 0x08, 0x2c, + }), + uint256(std::vector{ + 0xd6, 0xac, 0xde, 0xdf, 0x95, 0xf6, 0x08, 0xe0, + 0x9f, 0xa5, 0x3f, 0xb4, 0x3d, 0xcd, 0x09, 0x90, + 0x47, 0x57, 0x26, 0xc5, 0x13, 0x12, 0x10, 0xc9, + 0xe5, 0xca, 0xea, 0xb9, 0x7f, 0x0e, 0x64, 0x2f, + }), + uint256(std::vector{ + 0x1e, 0xa6, 0x67, 0x5f, 0x95, 0x51, 0xee, 0xb9, + 0xdf, 0xaa, 0xa9, 0x24, 0x7b, 0xc9, 0x85, 0x82, + 0x70, 0xd3, 0xd3, 0xa4, 0xc5, 0xaf, 0xa7, 0x17, + 0x7a, 0x98, 0x4d, 0x5e, 0xd1, 0xbe, 0x24, 0x51, + }), + uint256(std::vector{ + 0x6e, 0xdb, 0x16, 0xd0, 0x19, 0x07, 0xb7, 0x59, + 0x97, 0x7d, 0x76, 0x50, 0xda, 0xd7, 0xe3, 0xec, + 0x04, 0x9a, 0xf1, 0xa3, 0xd8, 0x75, 0x38, 0x0b, + 0x69, 0x7c, 0x86, 0x2c, 0x9e, 0xc5, 0xd5, 0x1c, + }), + uint256(std::vector{ + 0xcd, 0x1c, 0x8d, 0xbf, 0x6e, 0x3a, 0xcc, 0x7a, + 0x80, 0x43, 0x9b, 0xc4, 0x96, 0x2c, 0xf2, 0x5b, + 0x9d, 0xce, 0x7c, 0x89, 0x6f, 0x3a, 0x5b, 0xd7, + 0x08, 0x03, 0xfc, 0x5a, 0x0e, 0x33, 0xcf, 0x00, + }), + uint256(std::vector{ + 0x6a, 0xca, 0x84, 0x48, 0xd8, 0x26, 0x3e, 0x54, + 0x7d, 0x5f, 0xf2, 0x95, 0x0e, 0x2e, 0xd3, 0x83, + 0x9e, 0x99, 0x8d, 0x31, 0xcb, 0xc6, 0xac, 0x9f, + 0xd5, 0x7b, 0xc6, 0x00, 0x2b, 0x15, 0x92, 0x16, + }), + uint256(std::vector{ + 0x8d, 0x5f, 0xa4, 0x3e, 0x5a, 0x10, 0xd1, 0x16, + 0x05, 0xac, 0x74, 0x30, 0xba, 0x1f, 0x5d, 0x81, + 0xfb, 0x1b, 0x68, 0xd2, 0x9a, 0x64, 0x04, 0x05, + 0x76, 0x77, 0x49, 0xe8, 0x41, 0x52, 0x76, 0x73, + }), + uint256(std::vector{ + 0x08, 0xee, 0xab, 0x0c, 0x13, 0xab, 0xd6, 0x06, + 0x9e, 0x63, 0x10, 0x19, 0x7b, 0xf8, 0x0f, 0x9c, + 0x1e, 0xa6, 0xde, 0x78, 0xfd, 0x19, 0xcb, 0xae, + 0x24, 0xd4, 0xa5, 0x20, 0xe6, 0xcf, 0x30, 0x23, + }), + uint256(std::vector{ + 0x07, 0x69, 0x55, 0x7b, 0xc6, 0x82, 0xb1, 0xbf, + 0x30, 0x86, 0x46, 0xfd, 0x0b, 0x22, 0xe6, 0x48, + 0xe8, 0xb9, 0xe9, 0x8f, 0x57, 0xe2, 0x9f, 0x5a, + 0xf4, 0x0f, 0x6e, 0xdb, 0x83, 0x3e, 0x2c, 0x49, + }), + uint256(std::vector{ + 0x4c, 0x69, 0x37, 0xd7, 0x8f, 0x42, 0x68, 0x5f, + 0x84, 0xb4, 0x3a, 0xd3, 0xb7, 0xb0, 0x0f, 0x81, + 0x28, 0x56, 0x62, 0xf8, 0x5c, 0x6a, 0x68, 0xef, + 0x11, 0xd6, 0x2a, 0xd1, 0xa3, 0xee, 0x08, 0x50, + }), + uint256(std::vector{ + 0xfe, 0xe0, 0xe5, 0x28, 0x02, 0xcb, 0x0c, 0x46, + 0xb1, 0xeb, 0x4d, 0x37, 0x6c, 0x62, 0x69, 0x7f, + 0x47, 0x59, 0xf6, 0xc8, 0x91, 0x7f, 0xa3, 0x52, + 0x57, 0x12, 0x02, 0xfd, 0x77, 0x8f, 0xd7, 0x12, + }), + uint256(std::vector{ + 0x16, 0xd6, 0x25, 0x29, 0x68, 0x97, 0x1a, 0x83, + 0xda, 0x85, 0x21, 0xd6, 0x53, 0x82, 0xe6, 0x1f, + 0x01, 0x76, 0x64, 0x6d, 0x77, 0x1c, 0x91, 0x52, + 0x8e, 0x32, 0x76, 0xee, 0x45, 0x38, 0x3e, 0x4a, + }), + uint256(std::vector{ + 0xd2, 0xe1, 0x64, 0x2c, 0x9a, 0x46, 0x22, 0x29, + 0x28, 0x9e, 0x5b, 0x0e, 0x3b, 0x7f, 0x90, 0x08, + 0xe0, 0x30, 0x1c, 0xbb, 0x93, 0x38, 0x5e, 0xe0, + 0xe2, 0x1d, 0xa2, 0x54, 0x50, 0x73, 0xcb, 0x58, + }), + uint256(std::vector{ + 0xa5, 0x12, 0x2c, 0x08, 0xff, 0x9c, 0x16, 0x1d, + 0x9c, 0xa6, 0xfc, 0x46, 0x20, 0x73, 0x39, 0x6c, + 0x7d, 0x7d, 0x38, 0xe8, 0xee, 0x48, 0xcd, 0xb3, + 0xbe, 0xa7, 0xe2, 0x23, 0x01, 0x34, 0xed, 0x6a, + }), + uint256(std::vector{ + 0x28, 0xe7, 0xb8, 0x41, 0xdc, 0xbc, 0x47, 0xcc, + 0xeb, 0x69, 0xd7, 0xcb, 0x8d, 0x94, 0x24, 0x5f, + 0xb7, 0xcb, 0x2b, 0xa3, 0xa7, 0xa6, 0xbc, 0x18, + 0xf1, 0x3f, 0x94, 0x5f, 0x7d, 0xbd, 0x6e, 0x2a, + }), + uint256(std::vector{ + 0xe1, 0xf3, 0x4b, 0x03, 0x4d, 0x4a, 0x3c, 0xd2, + 0x85, 0x57, 0xe2, 0x90, 0x7e, 0xbf, 0x99, 0x0c, + 0x91, 0x8f, 0x64, 0xec, 0xb5, 0x0a, 0x94, 0xf0, + 0x1d, 0x6f, 0xda, 0x5c, 0xa5, 0xc7, 0xef, 0x72, + }), + uint256(std::vector{ + 0x12, 0x93, 0x5f, 0x14, 0xb6, 0x76, 0x50, 0x9b, + 0x81, 0xeb, 0x49, 0xef, 0x25, 0xf3, 0x92, 0x69, + 0xed, 0x72, 0x30, 0x92, 0x38, 0xb4, 0xc1, 0x45, + 0x80, 0x35, 0x44, 0xb6, 0x46, 0xdc, 0xa6, 0x2d, + }), + uint256(std::vector{ + 0xb2, 0xee, 0xd0, 0x31, 0xd4, 0xd6, 0xa4, 0xf0, + 0x2a, 0x09, 0x7f, 0x80, 0xb5, 0x4c, 0xc1, 0x54, + 0x1d, 0x41, 0x63, 0xc6, 0xb6, 0xf5, 0x97, 0x1f, + 0x88, 0xb6, 0xe4, 0x1d, 0x35, 0xc5, 0x38, 0x14, + }), + uint256(std::vector{ + 0xfb, 0xc2, 0xf4, 0x30, 0x0c, 0x01, 0xf0, 0xb7, + 0x82, 0x0d, 0x00, 0xe3, 0x34, 0x7c, 0x8d, 0xa4, + 0xee, 0x61, 0x46, 0x74, 0x37, 0x6c, 0xbc, 0x45, + 0x35, 0x9d, 0xaa, 0x54, 0xf9, 0xb5, 0x49, 0x3e, + }), + uint256(std::vector{ + 0x25, 0x2e, 0x67, 0x98, 0x64, 0x5f, 0x5b, 0xf1, + 0x14, 0xe4, 0xb4, 0xe9, 0x0e, 0x96, 0x18, 0x28, + 0x61, 0x48, 0x98, 0x40, 0xd9, 0xb4, 0xcc, 0xc4, + 0xc1, 0xfb, 0x5a, 0x46, 0x99, 0x7c, 0xee, 0x14, + }), + uint256(std::vector{ + 0x98, 0xb1, 0x90, 0x42, 0xf1, 0xf7, 0xc7, 0xdd, + 0x11, 0xec, 0x25, 0xea, 0x66, 0xb6, 0xff, 0x74, + 0xe0, 0x8c, 0xe1, 0x1d, 0x44, 0x7e, 0xd6, 0xf1, + 0xbf, 0xe8, 0x7e, 0x11, 0x0e, 0x33, 0x1e, 0x11, + }), + uint256(std::vector{ + 0xd4, 0x51, 0x30, 0x47, 0x99, 0x57, 0x2b, 0xa9, + 0xf4, 0x2c, 0x4d, 0xab, 0x6b, 0x07, 0xc7, 0x03, + 0xbd, 0x2c, 0x12, 0x3a, 0xb9, 0xd6, 0x0f, 0x2a, + 0x60, 0xf9, 0x95, 0x58, 0x54, 0x91, 0x0b, 0x6a, + }), + uint256(std::vector{ + 0x3e, 0xcd, 0x5f, 0x27, 0xac, 0xf0, 0x1b, 0xd3, + 0x7a, 0x33, 0xe4, 0x51, 0x78, 0x67, 0xef, 0x76, + 0x47, 0x4c, 0xd8, 0x3f, 0xb3, 0x1c, 0x92, 0x08, + 0xdc, 0xef, 0x2e, 0xed, 0xce, 0xf3, 0x6c, 0x72, + }), + uint256(std::vector{ + 0x26, 0xc3, 0x7d, 0xa6, 0x78, 0x94, 0xa1, 0x3d, + 0xf8, 0xaa, 0x48, 0x78, 0xd2, 0x51, 0x4a, 0x42, + 0x12, 0x57, 0x3b, 0x73, 0xec, 0xca, 0xab, 0x16, + 0xfe, 0x4f, 0xa6, 0x60, 0xe8, 0xfe, 0x27, 0x07, + }), + uint256(std::vector{ + 0xb5, 0x45, 0xef, 0x34, 0x48, 0x5e, 0xed, 0x30, + 0xd4, 0x2b, 0x2c, 0x29, 0x5a, 0x4a, 0x5b, 0x68, + 0x0d, 0xe8, 0xa9, 0xd5, 0xe3, 0x83, 0x45, 0x78, + 0x24, 0x62, 0xc0, 0x4f, 0x09, 0xdc, 0x68, 0x51, + }), + uint256(std::vector{ + 0x77, 0xfd, 0x20, 0xb3, 0x00, 0x94, 0x67, 0x65, + 0xa8, 0x7f, 0x24, 0xbd, 0x04, 0x50, 0x73, 0x72, + 0x9c, 0xbd, 0x7b, 0x66, 0xeb, 0x8f, 0xa1, 0x40, + 0xb5, 0x83, 0xfa, 0xa9, 0xd1, 0x42, 0x58, 0x01, + }), + uint256(std::vector{ + 0xcb, 0xaa, 0x57, 0x6b, 0x17, 0x99, 0xb5, 0x8f, + 0xf3, 0xa6, 0xde, 0xcb, 0xba, 0x91, 0x9b, 0x0b, + 0x68, 0xd7, 0xc8, 0x93, 0xe4, 0x6f, 0xde, 0x99, + 0x87, 0x68, 0xe8, 0x7e, 0x35, 0x0a, 0x07, 0x25, + }), + uint256(std::vector{ + 0x45, 0xfe, 0x81, 0xb1, 0x8c, 0xa3, 0x00, 0x74, + 0xd0, 0x12, 0x0d, 0x2b, 0x1a, 0x0d, 0x10, 0xb3, + 0xa0, 0x50, 0x93, 0x35, 0x12, 0xdb, 0x8e, 0xe3, + 0x4e, 0x52, 0x47, 0x3d, 0x4f, 0x08, 0xa2, 0x67, + }), + uint256(std::vector{ + 0x0e, 0x60, 0xa1, 0xf0, 0x12, 0x1f, 0x59, 0x1e, + 0x55, 0x1d, 0x3e, 0xd1, 0x86, 0x5b, 0x50, 0xa7, + 0x5d, 0x7c, 0xcf, 0xf1, 0x28, 0x9d, 0xf7, 0xc4, + 0x4d, 0xd4, 0x65, 0xa5, 0x43, 0x17, 0xf5, 0x6a, + }), + uint256(std::vector{ + 0xce, 0xdf, 0xb1, 0x84, 0xdd, 0x92, 0xa0, 0xcb, + 0xfc, 0x11, 0xe8, 0xbe, 0x69, 0x7b, 0x47, 0x69, + 0x88, 0xed, 0x5f, 0x39, 0x36, 0x9a, 0xbd, 0xd9, + 0x0c, 0x61, 0x54, 0x49, 0x88, 0x60, 0x1c, 0x0d, + }), + uint256(std::vector{ + 0xf3, 0x62, 0x68, 0x66, 0x12, 0x64, 0x9a, 0x31, + 0x3b, 0xa4, 0x64, 0x43, 0x7a, 0x0c, 0xad, 0x0e, + 0x7e, 0x3d, 0x7e, 0x1b, 0x4b, 0x37, 0x43, 0xf9, + 0x0e, 0x05, 0xa2, 0x10, 0x0a, 0x49, 0x5f, 0x42, + }), + uint256(std::vector{ + 0x7d, 0xea, 0xe5, 0xf3, 0xbb, 0xde, 0xff, 0xd3, + 0xf8, 0x52, 0x71, 0xa0, 0x8b, 0x5e, 0xc3, 0x1f, + 0x16, 0xf9, 0x37, 0x96, 0x4a, 0xe7, 0x08, 0xfd, + 0xff, 0x7c, 0x13, 0xe5, 0xa4, 0xf3, 0xdf, 0x6b, + }), + uint256(std::vector{ + 0x40, 0xcc, 0xf0, 0xfc, 0x1e, 0xab, 0x6d, 0x85, + 0x02, 0xbd, 0x93, 0xdc, 0x31, 0x34, 0x2d, 0xfd, + 0x57, 0xdf, 0x5b, 0xbb, 0x5d, 0x70, 0xa1, 0xbf, + 0x6b, 0x92, 0xef, 0xc6, 0x1e, 0xc9, 0xa2, 0x58, + }), + uint256(std::vector{ + 0xd7, 0x80, 0x25, 0x49, 0x1f, 0x1b, 0xca, 0x85, + 0x07, 0xf6, 0x4f, 0x25, 0x87, 0x2d, 0xd0, 0x23, + 0x88, 0x47, 0x9a, 0x1a, 0x22, 0x51, 0x26, 0xe4, + 0x0d, 0x2f, 0xe4, 0x18, 0xb9, 0x8e, 0x0e, 0x2c, + }), + uint256(std::vector{ + 0x0d, 0xb7, 0x29, 0x46, 0x85, 0xc8, 0xa0, 0x72, + 0x5f, 0x15, 0x84, 0x6e, 0xa5, 0x89, 0x9e, 0xa0, + 0xe9, 0x86, 0xc2, 0x70, 0x7b, 0xd7, 0xb4, 0x12, + 0x95, 0x44, 0x12, 0xf2, 0x6a, 0xbf, 0x55, 0x0a, + }), + uint256(std::vector{ + 0xb7, 0xe2, 0x90, 0xbe, 0x95, 0x55, 0xcf, 0x75, + 0x54, 0x86, 0x50, 0xda, 0x6d, 0x47, 0xc8, 0x93, + 0xae, 0xf7, 0xf8, 0xc6, 0xdd, 0x27, 0x35, 0x49, + 0x94, 0x95, 0xf6, 0x36, 0x59, 0x0d, 0xae, 0x0a, + }), + uint256(std::vector{ + 0x2d, 0xd2, 0x53, 0x2a, 0x85, 0x8c, 0x30, 0x01, + 0x45, 0xa6, 0x5e, 0x35, 0x1f, 0x91, 0xbe, 0x6a, + 0xfe, 0xab, 0x59, 0x7c, 0x41, 0xef, 0x07, 0x3f, + 0x50, 0xb6, 0x22, 0xd5, 0x86, 0xff, 0x59, 0x27, + }), + uint256(std::vector{ + 0x97, 0x2f, 0x0c, 0x5c, 0x6f, 0x9a, 0xeb, 0x0e, + 0x38, 0xbf, 0x83, 0x19, 0xf3, 0xa5, 0xfc, 0xdc, + 0x8f, 0xd8, 0x78, 0x2e, 0x41, 0x88, 0x73, 0x0c, + 0xd0, 0x82, 0xd9, 0xba, 0xbc, 0x58, 0x98, 0x51, + }), + uint256(std::vector{ + 0x00, 0x1e, 0x57, 0x7b, 0x0f, 0x43, 0x90, 0x18, + 0x2b, 0x4a, 0xe4, 0x3d, 0x32, 0x9b, 0x3a, 0xa8, + 0x83, 0x5d, 0xae, 0x1b, 0xb7, 0x9e, 0x60, 0x4b, + 0x7d, 0x2d, 0xa0, 0xe9, 0x0d, 0x06, 0x09, 0x29, + }), + uint256(std::vector{ + 0xaa, 0x6e, 0x70, 0xa9, 0x1e, 0xbc, 0x54, 0xee, + 0xfc, 0xe5, 0xff, 0xd5, 0xb6, 0x75, 0xda, 0xf3, + 0xf1, 0xd9, 0x40, 0xa8, 0x45, 0x1f, 0xcb, 0x01, + 0x08, 0x1f, 0xa9, 0xd4, 0xf2, 0x62, 0x43, 0x6f, + }), + uint256(std::vector{ + 0xd7, 0x70, 0x38, 0xbf, 0x67, 0xe6, 0x31, 0x75, + 0x29, 0x40, 0x23, 0x12, 0x51, 0xd7, 0xfe, 0x85, + 0xaf, 0x52, 0xdb, 0xdd, 0x6a, 0xab, 0x37, 0xc7, + 0xa5, 0xec, 0x32, 0xb6, 0x5f, 0xe6, 0xde, 0x03, + }), + uint256(std::vector{ + 0xd2, 0x27, 0xa1, 0x7a, 0x7e, 0x0c, 0xf9, 0x6d, + 0xce, 0xdd, 0x9f, 0xc7, 0xbc, 0xe4, 0x3c, 0x6c, + 0x1d, 0x66, 0xba, 0xdd, 0x75, 0x43, 0xa8, 0x87, + 0xc8, 0x65, 0x6c, 0x54, 0x7e, 0xcf, 0xb2, 0x4f, + }), + uint256(std::vector{ + 0x70, 0xe8, 0xa5, 0x21, 0x95, 0x15, 0x83, 0xe5, + 0x3f, 0xc0, 0x58, 0x5c, 0x70, 0x7e, 0xce, 0xda, + 0x89, 0xb7, 0xa7, 0xd1, 0xaf, 0x41, 0xd1, 0xa0, + 0x15, 0xd7, 0x97, 0xfa, 0x76, 0xc0, 0xf5, 0x69, + }), + uint256(std::vector{ + 0xe4, 0x85, 0xa9, 0x68, 0x55, 0xe8, 0x72, 0xfc, + 0x50, 0x90, 0x15, 0x0e, 0x2c, 0xd2, 0x4e, 0x10, + 0x59, 0x1d, 0x35, 0x16, 0x6e, 0xb0, 0xeb, 0x30, + 0xfc, 0xdf, 0xac, 0x93, 0xb0, 0x1d, 0x28, 0x1c, + }), + uint256(std::vector{ + 0xe4, 0xa1, 0x9f, 0xeb, 0xdf, 0x2a, 0x86, 0x89, + 0x6e, 0x41, 0xf2, 0xce, 0xdc, 0xf2, 0xae, 0x58, + 0x46, 0x71, 0x80, 0x2e, 0x6a, 0x46, 0x7e, 0x84, + 0x39, 0xca, 0xb5, 0xd6, 0x18, 0x43, 0x41, 0x6b, + }), + uint256(std::vector{ + 0xe9, 0x27, 0x83, 0x88, 0x47, 0x80, 0x6a, 0x43, + 0xbd, 0x6c, 0x60, 0x88, 0xe3, 0x9f, 0x65, 0xb8, + 0xb3, 0xe5, 0x8b, 0x2d, 0xb5, 0xf7, 0xad, 0x56, + 0x43, 0xd9, 0x1e, 0x06, 0x59, 0xa2, 0x8a, 0x2a, + }), + uint256(std::vector{ + 0x0b, 0xd3, 0xa8, 0x18, 0xe8, 0x3f, 0x9c, 0xd2, + 0xff, 0x4f, 0x62, 0x01, 0x1a, 0x51, 0x01, 0x76, + 0xac, 0x32, 0xf5, 0x44, 0x8e, 0x6e, 0x15, 0x45, + 0x15, 0x04, 0x3c, 0x59, 0x26, 0xd5, 0x1c, 0x6f, + }), + uint256(std::vector{ + 0xce, 0x41, 0x34, 0x45, 0xe0, 0x37, 0x90, 0x49, + 0x8f, 0xe7, 0x2d, 0x8e, 0x01, 0x91, 0x5e, 0x7f, + 0xf1, 0x20, 0xae, 0x35, 0xb3, 0xb5, 0x90, 0xd2, + 0x1b, 0x7f, 0x74, 0xde, 0xe1, 0x83, 0x0f, 0x0d, + }), + uint256(std::vector{ + 0x60, 0x0e, 0x6f, 0x93, 0xe7, 0x3d, 0x7a, 0xbd, + 0x4e, 0xe0, 0xa6, 0x5c, 0xb1, 0xb1, 0x9a, 0xa3, + 0xec, 0xc5, 0x25, 0x68, 0x9d, 0xbf, 0x17, 0x77, + 0x96, 0x58, 0x74, 0x1b, 0x95, 0xc1, 0x5a, 0x55, + }), +}; + +PedersenHash PedersenHash::EmptyRoot(size_t depth) { + assert(depth <= sizeof(pedersen_empty_roots)/sizeof(pedersen_empty_roots[0])); + return pedersen_empty_roots[depth]; +} + SHA256Compress SHA256Compress::combine( const SHA256Compress& a, const SHA256Compress& b, @@ -51,6 +437,410 @@ SHA256Compress SHA256Compress::combine( return res; } +static const std::array sha256_empty_roots = { + uint256(std::vector{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }), + uint256(std::vector{ + 0xda, 0x56, 0x98, 0xbe, 0x17, 0xb9, 0xb4, 0x69, + 0x62, 0x33, 0x57, 0x99, 0x77, 0x9f, 0xbe, 0xca, + 0x8c, 0xe5, 0xd4, 0x91, 0xc0, 0xd2, 0x62, 0x43, + 0xba, 0xfe, 0xf9, 0xea, 0x18, 0x37, 0xa9, 0xd8, + }), + uint256(std::vector{ + 0xdc, 0x76, 0x6f, 0xab, 0x49, 0x2c, 0xcf, 0x3d, + 0x1e, 0x49, 0xd4, 0xf3, 0x74, 0xb5, 0x23, 0x5f, + 0xa5, 0x65, 0x06, 0xaa, 0xc2, 0x22, 0x4d, 0x39, + 0xf9, 0x43, 0xfc, 0xd4, 0x92, 0x02, 0x97, 0x4c, + }), + uint256(std::vector{ + 0x3f, 0x0a, 0x40, 0x61, 0x81, 0x10, 0x59, 0x68, + 0xfd, 0xae, 0xe3, 0x06, 0x79, 0xe3, 0x27, 0x3c, + 0x66, 0xb7, 0x2b, 0xf9, 0xa7, 0xf5, 0xde, 0xbb, + 0xf3, 0xb5, 0xa0, 0xa2, 0x6e, 0x35, 0x9f, 0x92, + }), + uint256(std::vector{ + 0x26, 0xb0, 0x05, 0x26, 0x94, 0xfc, 0x42, 0xfd, + 0xff, 0x93, 0xe6, 0xfb, 0x5a, 0x71, 0xd3, 0x8c, + 0x3d, 0xd7, 0xdc, 0x5b, 0x6a, 0xd7, 0x10, 0xeb, + 0x04, 0x8c, 0x66, 0x02, 0x33, 0x13, 0x7f, 0xab, + }), + uint256(std::vector{ + 0x01, 0x09, 0xec, 0xc0, 0x72, 0x26, 0x59, 0xff, + 0x83, 0x45, 0x0b, 0x8f, 0x7b, 0x88, 0x46, 0xe6, + 0x7b, 0x28, 0x59, 0xf3, 0x3c, 0x30, 0xd9, 0xb7, + 0xac, 0xd5, 0xbf, 0x39, 0xca, 0xe5, 0x4e, 0x31, + }), + uint256(std::vector{ + 0x3f, 0x90, 0x9b, 0x8c, 0xe3, 0xd7, 0xff, 0xd8, + 0xa5, 0xb3, 0x09, 0x08, 0xf6, 0x05, 0xa0, 0x3b, + 0x0d, 0xb8, 0x51, 0x69, 0x55, 0x8d, 0xdc, 0x1d, + 0xa7, 0xbb, 0xbc, 0xc9, 0xb0, 0x9f, 0xd3, 0x25, + }), + uint256(std::vector{ + 0x40, 0x46, 0x0f, 0xa6, 0xbc, 0x69, 0x2a, 0x06, + 0xf4, 0x75, 0x21, 0xa6, 0x72, 0x5a, 0x54, 0x7c, + 0x02, 0x8a, 0x6a, 0x24, 0x0d, 0x84, 0x09, 0xf1, + 0x65, 0xe6, 0x3c, 0xb5, 0x4d, 0xa2, 0xd2, 0x3f, + }), + uint256(std::vector{ + 0x8c, 0x08, 0x56, 0x74, 0x24, 0x9b, 0x43, 0xda, + 0x1b, 0x9a, 0x31, 0xa0, 0xe8, 0x20, 0xe8, 0x1e, + 0x75, 0xf3, 0x42, 0x80, 0x7b, 0x03, 0xb6, 0xb9, + 0xe6, 0x49, 0x83, 0x21, 0x7b, 0xc2, 0xb3, 0x8e, + }), + uint256(std::vector{ + 0xa0, 0x83, 0x45, 0x0c, 0x1b, 0xa2, 0xa3, 0xa7, + 0xbe, 0x76, 0xfa, 0xd9, 0xd1, 0x3b, 0xc3, 0x7b, + 0xe4, 0xbf, 0x83, 0xbd, 0x3e, 0x59, 0xfc, 0x37, + 0x5a, 0x36, 0xba, 0x62, 0xdc, 0x62, 0x02, 0x98, + }), + uint256(std::vector{ + 0x1d, 0xdd, 0xda, 0xbc, 0x2c, 0xaa, 0x2d, 0xe9, + 0xef, 0xf9, 0xe1, 0x8c, 0x8c, 0x5a, 0x39, 0x40, + 0x6d, 0x79, 0x36, 0xe8, 0x89, 0xbc, 0x16, 0xcf, + 0xab, 0xb1, 0x44, 0xf5, 0xc0, 0x02, 0x26, 0x82, + }), + uint256(std::vector{ + 0xc2, 0x2d, 0x8f, 0x0b, 0x5e, 0x40, 0x56, 0xe5, + 0xf3, 0x18, 0xba, 0x22, 0x09, 0x1c, 0xc0, 0x7d, + 0xb5, 0x69, 0x4f, 0xbe, 0xb5, 0xe8, 0x7e, 0xf0, + 0xd7, 0xe2, 0xc5, 0x7c, 0xa3, 0x52, 0x35, 0x9e, + }), + uint256(std::vector{ + 0x89, 0xa4, 0x34, 0xae, 0x1f, 0xeb, 0xd7, 0x68, + 0x7e, 0xce, 0xea, 0x21, 0xd0, 0x7f, 0x20, 0xa2, + 0x51, 0x24, 0x49, 0xd0, 0x8c, 0xe2, 0xee, 0xe5, + 0x58, 0x71, 0xcd, 0xb9, 0xd4, 0x6c, 0x12, 0x33, + }), + uint256(std::vector{ + 0x73, 0x33, 0xdb, 0xff, 0xbd, 0x11, 0xf0, 0x92, + 0x47, 0xa2, 0xb3, 0x3a, 0x01, 0x3e, 0xc4, 0xc4, + 0x34, 0x20, 0x29, 0xd8, 0x51, 0xe2, 0x2b, 0xa4, + 0x85, 0xd4, 0x46, 0x18, 0x51, 0x37, 0x0c, 0x15, + }), + uint256(std::vector{ + 0x5d, 0xad, 0x84, 0x4a, 0xb9, 0x46, 0x6b, 0x70, + 0xf7, 0x45, 0x13, 0x71, 0x95, 0xca, 0x22, 0x1b, + 0x48, 0xf3, 0x46, 0xab, 0xd1, 0x45, 0xfb, 0x5e, + 0xfc, 0x23, 0xa8, 0xb4, 0xba, 0x50, 0x80, 0x22, + }), + uint256(std::vector{ + 0x50, 0x7e, 0x0d, 0xae, 0x81, 0xcb, 0xfb, 0xe4, + 0x57, 0xfd, 0x37, 0x0e, 0xf1, 0xca, 0x42, 0x01, + 0xc2, 0xb6, 0x40, 0x10, 0x83, 0xdd, 0xab, 0x44, + 0x0e, 0x4a, 0x03, 0x8d, 0xc1, 0xe3, 0x58, 0xc4, + }), + uint256(std::vector{ + 0xbd, 0xcd, 0xb3, 0x29, 0x31, 0x88, 0xc9, 0x80, + 0x7d, 0x80, 0x82, 0x67, 0x01, 0x86, 0x84, 0xcf, + 0xec, 0xe0, 0x7a, 0xc3, 0x5a, 0x42, 0xc0, 0x0f, + 0x2c, 0x79, 0xb4, 0x00, 0x38, 0x25, 0x30, 0x5d, + }), + uint256(std::vector{ + 0xba, 0xb5, 0x80, 0x09, 0x72, 0xa1, 0x6c, 0x2c, + 0x22, 0x53, 0x0c, 0x66, 0x06, 0x6d, 0x0a, 0x58, + 0x67, 0xe9, 0x87, 0xbe, 0xd2, 0x1a, 0x6d, 0x5a, + 0x45, 0x0b, 0x68, 0x3c, 0xf1, 0xcf, 0xd7, 0x09, + }), + uint256(std::vector{ + 0x11, 0xaa, 0x0b, 0x4a, 0xd2, 0x9b, 0x13, 0xb0, + 0x57, 0xa3, 0x16, 0x19, 0xd6, 0x50, 0x0d, 0x63, + 0x6c, 0xd7, 0x35, 0xcd, 0xd0, 0x7d, 0x81, 0x1e, + 0xa2, 0x65, 0xec, 0x4b, 0xcb, 0xbb, 0xd0, 0x58, + }), + uint256(std::vector{ + 0x51, 0x45, 0xb1, 0xb0, 0x55, 0xc2, 0xdf, 0x02, + 0xb9, 0x56, 0x75, 0xe3, 0x79, 0x7b, 0x91, 0xde, + 0x1b, 0x84, 0x6d, 0x25, 0x00, 0x3c, 0x0a, 0x80, + 0x3d, 0x08, 0x90, 0x07, 0x28, 0xf2, 0xcd, 0x6a, + }), + uint256(std::vector{ + 0x03, 0x23, 0xf2, 0x85, 0x0b, 0xf3, 0x44, 0x4f, + 0x4b, 0x4c, 0x5c, 0x09, 0xa6, 0x05, 0x7e, 0xc7, + 0x16, 0x91, 0x90, 0xf4, 0x5a, 0xcb, 0x9e, 0x46, + 0x98, 0x4a, 0xb3, 0xdf, 0xce, 0xc4, 0xf0, 0x6a, + }), + uint256(std::vector{ + 0x67, 0x15, 0x46, 0xe2, 0x6b, 0x1d, 0xa1, 0xaf, + 0x75, 0x45, 0x31, 0xe2, 0x6d, 0x8a, 0x6a, 0x51, + 0x07, 0x3a, 0x57, 0xdd, 0xd7, 0x2d, 0xc4, 0x72, + 0xef, 0xb4, 0x3f, 0xcb, 0x25, 0x7c, 0xff, 0xff, + }), + uint256(std::vector{ + 0xbb, 0x23, 0xa9, 0xbb, 0xa5, 0x6d, 0xe5, 0x7c, + 0xb2, 0x84, 0xb0, 0xd2, 0xb0, 0x1c, 0x64, 0x2c, + 0xf7, 0x9c, 0x9a, 0x55, 0x63, 0xf0, 0x06, 0x7a, + 0x21, 0x29, 0x24, 0x12, 0x14, 0x5b, 0xd7, 0x8a, + }), + uint256(std::vector{ + 0xf3, 0x0c, 0xc8, 0x36, 0xb9, 0xf7, 0x1b, 0x4e, + 0x7e, 0xe3, 0xc7, 0x2b, 0x1f, 0xd2, 0x53, 0x26, + 0x8a, 0xf9, 0xa2, 0x7e, 0x9d, 0x72, 0x91, 0xa2, + 0x3d, 0x02, 0x82, 0x1b, 0x21, 0xdd, 0xfd, 0x16, + }), + uint256(std::vector{ + 0x58, 0xa2, 0x75, 0x3d, 0xad, 0xe1, 0x03, 0xce, + 0xcb, 0xcd, 0xa5, 0x0b, 0x5e, 0xbf, 0xce, 0x31, + 0xe1, 0x2d, 0x41, 0xd5, 0x84, 0x1d, 0xcc, 0x95, + 0x62, 0x0f, 0x7b, 0x3d, 0x50, 0xa1, 0xb9, 0xa1, + }), + uint256(std::vector{ + 0x92, 0x5e, 0x6d, 0x47, 0x4a, 0x5d, 0x8d, 0x30, + 0x04, 0xf2, 0x9d, 0xa0, 0xdd, 0x78, 0xd3, 0x0a, + 0xe3, 0x82, 0x4c, 0xe7, 0x9d, 0xfe, 0x49, 0x34, + 0xbb, 0x29, 0xec, 0x3a, 0xfa, 0xf3, 0xd5, 0x21, + }), + uint256(std::vector{ + 0x08, 0xf2, 0x79, 0x61, 0x86, 0x16, 0xbc, 0xdd, + 0x4e, 0xad, 0xc9, 0xc7, 0xa9, 0x06, 0x26, 0x91, + 0xa5, 0x9b, 0x43, 0xb0, 0x7e, 0x2c, 0x1e, 0x23, + 0x7f, 0x17, 0xbd, 0x18, 0x9c, 0xd6, 0xa8, 0xfe, + }), + uint256(std::vector{ + 0xc9, 0x2b, 0x32, 0xdb, 0x42, 0xf4, 0x2e, 0x2b, + 0xf0, 0xa5, 0x9d, 0xf9, 0x05, 0x5b, 0xe5, 0xc6, + 0x69, 0xd3, 0x24, 0x2d, 0xf4, 0x53, 0x57, 0x65, + 0x9b, 0x75, 0xae, 0x2c, 0x27, 0xa7, 0x6f, 0x50, + }), + uint256(std::vector{ + 0xc0, 0xdb, 0x2a, 0x74, 0x99, 0x8c, 0x50, 0xeb, + 0x7b, 0xa6, 0x53, 0x4f, 0x6d, 0x41, 0x0e, 0xfc, + 0x27, 0xc4, 0xbb, 0x88, 0xac, 0xb0, 0x22, 0x2c, + 0x79, 0x06, 0xea, 0x28, 0xa3, 0x27, 0xb5, 0x11, + }), + uint256(std::vector{ + 0xd7, 0xc6, 0x12, 0xc8, 0x17, 0x79, 0x31, 0x91, + 0xa1, 0xe6, 0x86, 0x52, 0x12, 0x18, 0x76, 0xd6, + 0xb3, 0xbd, 0xe4, 0x0f, 0x4f, 0xa5, 0x2b, 0xc3, + 0x14, 0x14, 0x5c, 0xe6, 0xe5, 0xcd, 0xd2, 0x59, + }), + uint256(std::vector{ + 0xb2, 0x23, 0x70, 0x10, 0x6c, 0x67, 0xa1, 0x72, + 0x09, 0xf6, 0x13, 0x0b, 0xc0, 0x9f, 0x73, 0x5d, + 0x83, 0xaa, 0x2c, 0x04, 0xfc, 0x4f, 0xe7, 0x2e, + 0xa5, 0xd8, 0x0b, 0x21, 0x67, 0x23, 0xe7, 0xce, + }), + uint256(std::vector{ + 0x9f, 0x67, 0xd5, 0xf6, 0x64, 0x66, 0x4c, 0x90, + 0x19, 0x40, 0xee, 0xe3, 0xd0, 0x2d, 0xd5, 0xb3, + 0xe4, 0xb9, 0x2e, 0x7b, 0x42, 0x82, 0x0c, 0x42, + 0xfc, 0x51, 0x59, 0xe9, 0x1b, 0x41, 0x17, 0x2a, + }), + uint256(std::vector{ + 0xac, 0x58, 0xcd, 0x13, 0x88, 0xfe, 0xc2, 0x90, + 0xd3, 0x98, 0xf1, 0x94, 0x4b, 0x56, 0x44, 0x49, + 0xa6, 0x3c, 0x81, 0x58, 0x80, 0x56, 0x6b, 0xd1, + 0xd1, 0x89, 0xf7, 0x83, 0x9e, 0x3b, 0x0c, 0x8c, + }), + uint256(std::vector{ + 0x56, 0x98, 0xea, 0xe7, 0xc8, 0x51, 0x5e, 0xd0, + 0x5a, 0x70, 0x33, 0x9b, 0xdf, 0x7c, 0x10, 0x28, + 0xe7, 0xac, 0xca, 0x13, 0xa4, 0xfa, 0x97, 0xd9, + 0x53, 0x8f, 0x01, 0xac, 0x8d, 0x88, 0x9a, 0xe3, + }), + uint256(std::vector{ + 0x2d, 0x49, 0x95, 0x77, 0x0a, 0x76, 0xfb, 0x93, + 0x31, 0x4c, 0xa7, 0x4b, 0x35, 0x24, 0xea, 0x1d, + 0xb5, 0x68, 0x8a, 0xd0, 0xa7, 0x61, 0x83, 0xea, + 0x17, 0x20, 0x4a, 0x8f, 0x02, 0x4a, 0x9f, 0x3b, + }), + uint256(std::vector{ + 0x5e, 0x89, 0x92, 0xc1, 0xb0, 0x72, 0xc1, 0x6e, + 0x9e, 0x28, 0xa8, 0x53, 0x58, 0xfb, 0x5f, 0xb6, + 0x90, 0x1a, 0x81, 0x58, 0x77, 0x66, 0xda, 0xdb, + 0x7a, 0xa0, 0xb9, 0x73, 0xde, 0xd2, 0xf2, 0x64, + }), + uint256(std::vector{ + 0xe9, 0x5d, 0xb7, 0x1e, 0x1f, 0x72, 0x91, 0xba, + 0x54, 0x99, 0x46, 0x1b, 0xc7, 0x15, 0x20, 0x3e, + 0x29, 0xb8, 0x4b, 0xfa, 0x42, 0x83, 0xe3, 0xbb, + 0x7f, 0x47, 0x0a, 0x15, 0xd0, 0xe1, 0x58, 0x4e, + }), + uint256(std::vector{ + 0x41, 0xf0, 0x78, 0xbd, 0x18, 0x24, 0xc8, 0xa4, + 0xb7, 0x19, 0x64, 0xf3, 0x94, 0xaa, 0x59, 0x50, + 0x84, 0xd8, 0xeb, 0x17, 0xb9, 0x7a, 0x36, 0x30, + 0x43, 0x3a, 0xf7, 0x0d, 0x10, 0xe0, 0xef, 0xf6, + }), + uint256(std::vector{ + 0xa1, 0x91, 0x3f, 0xe6, 0xb2, 0x01, 0x32, 0x31, + 0x2f, 0x8c, 0x1f, 0x00, 0xdd, 0xd6, 0x3c, 0xec, + 0x7a, 0x03, 0xf5, 0xf1, 0xd7, 0xd8, 0x34, 0x92, + 0xfa, 0x28, 0x4c, 0x0b, 0x5d, 0x63, 0x20, 0xb0, + }), + uint256(std::vector{ + 0xba, 0x94, 0x40, 0xc4, 0xdb, 0xfc, 0xf5, 0x5c, + 0xeb, 0x60, 0x5a, 0x5b, 0x89, 0x90, 0xfc, 0x11, + 0xf8, 0xef, 0x22, 0x87, 0x0d, 0x8d, 0x12, 0xe1, + 0x30, 0xf9, 0x86, 0x49, 0x1e, 0xae, 0x84, 0xb3, + }), + uint256(std::vector{ + 0x49, 0xdb, 0x2d, 0x5e, 0x22, 0xb8, 0x01, 0x5c, + 0xae, 0x48, 0x10, 0xd7, 0x5e, 0x54, 0x01, 0x4c, + 0x54, 0x69, 0x86, 0x27, 0x38, 0xe1, 0x61, 0xec, + 0x96, 0xec, 0x20, 0x21, 0x87, 0x18, 0x82, 0x8a, + }), + uint256(std::vector{ + 0xd4, 0x85, 0x1f, 0xb8, 0x43, 0x1e, 0xdf, 0xbb, + 0x8b, 0x1e, 0x85, 0xad, 0xa6, 0x89, 0x59, 0x67, + 0xc2, 0xda, 0xc8, 0x7d, 0xf3, 0x44, 0x99, 0x2a, + 0x05, 0xfa, 0xf1, 0xec, 0xf8, 0x36, 0xee, 0xc9, + }), + uint256(std::vector{ + 0xe4, 0xab, 0x9f, 0x44, 0x70, 0xf0, 0x0c, 0xd1, + 0x96, 0xd4, 0x7c, 0x75, 0xc8, 0x2e, 0x7a, 0xda, + 0xf0, 0x6f, 0xe1, 0x7e, 0x04, 0x2e, 0x39, 0x53, + 0xd9, 0x3b, 0xb5, 0xd5, 0x6d, 0x8c, 0xd8, 0xfb, + }), + uint256(std::vector{ + 0x7e, 0x43, 0x20, 0x43, 0x48, 0x49, 0xec, 0xb3, + 0x57, 0xf1, 0xaf, 0xaa, 0xba, 0x21, 0xa5, 0x44, + 0x00, 0xef, 0x2d, 0x11, 0xcf, 0xf8, 0x3b, 0x93, + 0x7d, 0x87, 0xfd, 0xaf, 0xa4, 0x9f, 0x81, 0x99, + }), + uint256(std::vector{ + 0x02, 0x0a, 0xdc, 0x98, 0xd9, 0x6c, 0xfb, 0xbc, + 0xca, 0x15, 0xfc, 0x3a, 0xa0, 0x37, 0x60, 0xed, + 0x28, 0x66, 0x86, 0xc3, 0x5b, 0x5d, 0x92, 0xc7, + 0xcb, 0x64, 0xa9, 0x99, 0xb3, 0x94, 0xa8, 0x54, + }), + uint256(std::vector{ + 0x3a, 0x26, 0xb2, 0x9f, 0xe1, 0xac, 0xfd, 0xd6, + 0xc6, 0xa1, 0x51, 0xbc, 0xc3, 0xdb, 0xcb, 0x95, + 0xa1, 0x0e, 0xbe, 0x2f, 0x05, 0x53, 0xf8, 0x07, + 0x79, 0x56, 0x9b, 0x67, 0xb7, 0x24, 0x4e, 0x77, + }), + uint256(std::vector{ + 0xec, 0x2d, 0x09, 0x86, 0xe6, 0xa0, 0xdd, 0xf4, + 0x38, 0x97, 0xb2, 0xd4, 0xf2, 0x3b, 0xb0, 0x34, + 0xf5, 0x38, 0xff, 0xe0, 0x08, 0x27, 0xf3, 0x10, + 0xdc, 0x49, 0x63, 0xf3, 0x26, 0x7f, 0x0b, 0xfb, + }), + uint256(std::vector{ + 0xd4, 0x80, 0x73, 0xf8, 0x81, 0x9f, 0x81, 0xf0, + 0x35, 0x8e, 0x3f, 0xc3, 0x5a, 0x04, 0x7c, 0xc7, + 0x40, 0x82, 0xae, 0x1c, 0xb7, 0xee, 0x22, 0xfb, + 0x60, 0x9c, 0x01, 0x64, 0x93, 0x42, 0xd0, 0xe6, + }), + uint256(std::vector{ + 0xad, 0x80, 0x37, 0x60, 0x17, 0x93, 0xf1, 0x72, + 0x44, 0x1e, 0xcb, 0x00, 0xdc, 0x13, 0x8d, 0x9f, + 0xc5, 0x95, 0x71, 0x25, 0xec, 0xc3, 0x82, 0xec, + 0x65, 0xe3, 0x6f, 0x81, 0x7d, 0xc7, 0x99, 0xfb, + }), + uint256(std::vector{ + 0xca, 0x50, 0x0a, 0x54, 0x41, 0xf3, 0x6f, 0x4d, + 0xf6, 0x73, 0xd6, 0xb8, 0xed, 0x07, 0x5d, 0x36, + 0xda, 0xe2, 0xc7, 0xe6, 0x48, 0x14, 0x28, 0xc7, + 0x0a, 0x5a, 0x76, 0xb7, 0xa9, 0xbe, 0xbc, 0xe8, + }), + uint256(std::vector{ + 0x42, 0x2b, 0x6d, 0xdd, 0x47, 0x32, 0x31, 0xdc, + 0x4d, 0x56, 0xfe, 0x91, 0x34, 0x44, 0xcc, 0xd5, + 0x6f, 0x7c, 0x61, 0xf7, 0x47, 0xba, 0x57, 0xca, + 0x94, 0x6d, 0x5f, 0xef, 0x72, 0xd8, 0x40, 0xa0, + }), + uint256(std::vector{ + 0xab, 0x41, 0xf4, 0xec, 0xb7, 0xd7, 0x08, 0x96, + 0x15, 0x80, 0x0e, 0x19, 0xfc, 0xc5, 0x3b, 0x83, + 0x79, 0xed, 0x05, 0xee, 0x35, 0xc8, 0x25, 0x67, + 0x09, 0x55, 0x83, 0xfd, 0x90, 0xff, 0x30, 0x35, + }), + uint256(std::vector{ + 0xbb, 0xf7, 0x61, 0x82, 0x48, 0x35, 0x4c, 0xeb, + 0x1b, 0xc1, 0xfc, 0x9d, 0xbc, 0x42, 0xc4, 0x26, + 0xa4, 0xe2, 0xc1, 0xe0, 0xd4, 0x43, 0xc5, 0x68, + 0x3a, 0x92, 0x56, 0xc6, 0x2e, 0xcd, 0xc2, 0x6f, + }), + uint256(std::vector{ + 0xe5, 0x0a, 0xe7, 0x14, 0x79, 0xfc, 0x8e, 0xc5, + 0x69, 0x19, 0x2a, 0x13, 0x07, 0x2e, 0x01, 0x1a, + 0xfc, 0x24, 0x9f, 0x47, 0x1a, 0xf0, 0x95, 0x00, + 0xea, 0x39, 0xf7, 0x5d, 0x0a, 0xf8, 0x56, 0xbf, + }), + uint256(std::vector{ + 0xe7, 0x4c, 0x0b, 0x92, 0x20, 0x14, 0x7d, 0xb2, + 0xd5, 0x0a, 0x3b, 0x58, 0xd4, 0x13, 0x77, 0x5d, + 0x16, 0xc9, 0x84, 0x69, 0x0b, 0xe7, 0xd9, 0x0f, + 0x0b, 0xc4, 0x3d, 0x99, 0xdb, 0xa1, 0xb6, 0x89, + }), + uint256(std::vector{ + 0x29, 0x32, 0x4a, 0x0a, 0x48, 0xd1, 0x16, 0x57, + 0xa5, 0x1b, 0xa0, 0x8b, 0x00, 0x48, 0x79, 0xbf, + 0xcf, 0xc6, 0x6a, 0x1a, 0xcb, 0x7c, 0xe3, 0x6d, + 0xfe, 0x47, 0x8d, 0x26, 0x55, 0x48, 0x4b, 0x48, + }), + uint256(std::vector{ + 0x88, 0x95, 0x2e, 0x3d, 0x0a, 0xc0, 0x6c, 0xb1, + 0x6b, 0x66, 0x52, 0x01, 0x12, 0x22, 0x49, 0x65, + 0x9a, 0x22, 0x32, 0x5e, 0x01, 0xc8, 0x70, 0xf4, + 0x9e, 0x29, 0xda, 0x6b, 0x17, 0x57, 0xe0, 0x82, + }), + uint256(std::vector{ + 0xcd, 0xf8, 0x79, 0xf2, 0x43, 0x5b, 0x95, 0xaf, + 0x04, 0x2a, 0x3b, 0xf7, 0xb8, 0x50, 0xf7, 0x81, + 0x92, 0x46, 0xc8, 0x05, 0x28, 0x58, 0x03, 0xd6, + 0x7f, 0xfb, 0xf4, 0xf2, 0x95, 0xbe, 0xd0, 0x04, + }), + uint256(std::vector{ + 0xe0, 0x05, 0xe3, 0x24, 0x20, 0x0b, 0x4f, 0x42, + 0x8c, 0x62, 0xbc, 0x33, 0x31, 0xe6, 0x95, 0xc3, + 0x73, 0x60, 0x7c, 0xd0, 0xfa, 0xa9, 0x79, 0x03, + 0x41, 0xfa, 0x3b, 0xa1, 0xed, 0x22, 0x8b, 0xc5, + }), + uint256(std::vector{ + 0x35, 0x44, 0x47, 0x72, 0x7a, 0xa9, 0xa5, 0x3d, + 0xd8, 0x34, 0x5b, 0x6b, 0x6c, 0x69, 0x34, 0x43, + 0xe5, 0x6e, 0xf4, 0xae, 0xba, 0x13, 0xc4, 0x10, + 0x17, 0x9f, 0xc8, 0x58, 0x9e, 0x77, 0x33, 0xd5, + }), + uint256(std::vector{ + 0xda, 0x52, 0xdd, 0xa9, 0x1f, 0x28, 0x29, 0xc1, + 0x5c, 0x0e, 0x58, 0xd2, 0x9a, 0x95, 0x36, 0x0b, + 0x86, 0xab, 0x30, 0xcf, 0x0c, 0xac, 0x81, 0x01, + 0x83, 0x2a, 0x29, 0xf3, 0x8c, 0x31, 0x85, 0xf1, + }), + uint256(std::vector{ + 0xc7, 0xda, 0x78, 0x14, 0xe2, 0x28, 0xe1, 0x14, + 0x44, 0x11, 0xd7, 0x8b, 0x53, 0x60, 0x92, 0xfe, + 0x92, 0x0b, 0xcd, 0xfc, 0xc3, 0x6c, 0xf1, 0x9d, + 0x12, 0x59, 0x04, 0x7b, 0x26, 0x7d, 0x58, 0xb5, + }), + uint256(std::vector{ + 0xab, 0xa1, 0xf6, 0x8b, 0x6c, 0x2b, 0x4d, 0xb6, + 0xcc, 0x06, 0xa7, 0x34, 0x0e, 0x12, 0x31, 0x3c, + 0x4b, 0x4a, 0x4e, 0xa6, 0xde, 0xb1, 0x7d, 0xeb, + 0x3e, 0x1e, 0x66, 0xcd, 0x8e, 0xac, 0xf3, 0x2b, + }), + uint256(std::vector{ + 0xc1, 0x60, 0xae, 0x4f, 0x64, 0xab, 0x76, 0x4d, + 0x86, 0x4a, 0x52, 0xad, 0x5e, 0x33, 0x12, 0x6c, + 0x4b, 0x5c, 0xe1, 0x05, 0xa4, 0x7d, 0xee, 0xdd, + 0x75, 0xbc, 0x70, 0x19, 0x9a, 0x52, 0x47, 0xef, + }), + uint256(std::vector{ + 0xea, 0xdf, 0x23, 0xfc, 0x99, 0xd5, 0x14, 0xdd, + 0x8e, 0xa2, 0x04, 0xd2, 0x23, 0xe9, 0x8d, 0xa9, + 0x88, 0x83, 0x1f, 0x9b, 0x5d, 0x19, 0x40, 0x27, + 0x4c, 0xa5, 0x20, 0xb7, 0xfb, 0x17, 0x3d, 0x8a, + }), + uint256(std::vector{ + 0x5b, 0x8e, 0x14, 0xfa, 0xca, 0xc8, 0xa7, 0xc7, + 0xa3, 0xbf, 0xee, 0x8b, 0xae, 0x71, 0xf2, 0xf7, + 0x79, 0x3d, 0x3a, 0xd5, 0xfe, 0x33, 0x83, 0xf9, + 0x3a, 0xb6, 0x06, 0x1f, 0x2a, 0x11, 0xbb, 0x02 + }), +}; + +SHA256Compress SHA256Compress::EmptyRoot(size_t depth) { + assert(depth <= sizeof(sha256_empty_roots)/sizeof(sha256_empty_roots[0])); + return sha256_empty_roots[depth]; +} + template class PathFiller { private: diff --git a/src/zcash/IncrementalMerkleTree.hpp b/src/zcash/IncrementalMerkleTree.hpp index 79a90bc5b..1ebb2b499 100644 --- a/src/zcash/IncrementalMerkleTree.hpp +++ b/src/zcash/IncrementalMerkleTree.hpp @@ -57,14 +57,9 @@ public: template class EmptyMerkleRoots { public: - EmptyMerkleRoots() { - empty_roots.at(0) = Hash::uncommitted(); - for (size_t d = 1; d <= Depth; d++) { - empty_roots.at(d) = Hash::combine(empty_roots.at(d-1), empty_roots.at(d-1), d-1); - } - } - Hash empty_root(size_t depth) { - return empty_roots.at(depth); + EmptyMerkleRoots() { } + Hash empty_root(size_t depth) const { + return Hash::EmptyRoot(depth); } template friend bool operator==(const EmptyMerkleRoots& a, @@ -227,6 +222,7 @@ public: static SHA256Compress uncommitted() { return SHA256Compress(); } + static SHA256Compress EmptyRoot(size_t); }; class PedersenHash : public uint256 { @@ -241,6 +237,7 @@ public: ); static PedersenHash uncommitted(); + static PedersenHash EmptyRoot(size_t); }; template From a3eb2b8708a8ebe376cad8b2bce117769f2fe654 Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Fri, 13 Sep 2019 09:12:05 -0600 Subject: [PATCH 2/3] update unit tests to compute empty roots --- src/Makefile.test.include | 2 - src/gtest/test_merkletree.cpp | 22 +++--- src/test/data/merkle_roots_empty.json | 68 ------------------- src/test/data/merkle_roots_empty_sapling.json | 65 ------------------ 4 files changed, 12 insertions(+), 145 deletions(-) delete mode 100644 src/test/data/merkle_roots_empty.json delete mode 100644 src/test/data/merkle_roots_empty_sapling.json diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 42ca0d138..a73e0ed71 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -33,13 +33,11 @@ JSON_TEST_FILES = \ test/data/tx_valid.json \ test/data/sighash.json \ test/data/merkle_roots.json \ - test/data/merkle_roots_empty.json \ test/data/merkle_serialization.json \ test/data/merkle_witness_serialization.json \ test/data/merkle_path.json \ test/data/merkle_commitments.json \ test/data/merkle_roots_sapling.json \ - test/data/merkle_roots_empty_sapling.json \ test/data/merkle_serialization_sapling.json \ test/data/merkle_witness_serialization_sapling.json \ test/data/merkle_path_sapling.json \ diff --git a/src/gtest/test_merkletree.cpp b/src/gtest/test_merkletree.cpp index dd9fbf850..ad3c2ad06 100644 --- a/src/gtest/test_merkletree.cpp +++ b/src/gtest/test_merkletree.cpp @@ -1,14 +1,12 @@ #include #include "test/data/merkle_roots.json.h" -#include "test/data/merkle_roots_empty.json.h" #include "test/data/merkle_serialization.json.h" #include "test/data/merkle_witness_serialization.json.h" #include "test/data/merkle_path.json.h" #include "test/data/merkle_commitments.json.h" #include "test/data/merkle_roots_sapling.json.h" -#include "test/data/merkle_roots_empty_sapling.json.h" #include "test/data/merkle_serialization_sapling.json.h" #include "test/data/merkle_witness_serialization_sapling.json.h" #include "test/data/merkle_path_sapling.json.h" @@ -165,12 +163,14 @@ TEST(merkletree, SaplingVectors) { } TEST(merkletree, emptyroots) { - UniValue empty_roots = read_json(MAKE_STRING(json_tests::merkle_roots_empty)); - libzcash::EmptyMerkleRoots<64, libzcash::SHA256Compress> emptyroots; + std::array computed; - for (size_t depth = 0; depth <= 64; depth++) { - expect_test_vector(empty_roots[depth], emptyroots.empty_root(depth)); + computed.at(0) = libzcash::SHA256Compress::uncommitted(); + ASSERT_TRUE(emptyroots.empty_root(0) == computed.at(0)); + for (size_t d = 1; d <= 64; d++) { + computed.at(d) = libzcash::SHA256Compress::combine(computed.at(d-1), computed.at(d-1), d-1); + ASSERT_TRUE(emptyroots.empty_root(d) == computed.at(d)); } // Double check that we're testing (at least) all the empty roots we'll use. @@ -178,12 +178,14 @@ TEST(merkletree, emptyroots) { } TEST(merkletree, EmptyrootsSapling) { - UniValue empty_roots = read_json(MAKE_STRING(json_tests::merkle_roots_empty_sapling)); - libzcash::EmptyMerkleRoots<62, libzcash::PedersenHash> emptyroots; + std::array computed; - for (size_t depth = 0; depth <= 62; depth++) { - expect_test_vector(empty_roots[depth], emptyroots.empty_root(depth)); + computed.at(0) = libzcash::PedersenHash::uncommitted(); + ASSERT_TRUE(emptyroots.empty_root(0) == computed.at(0)); + for (size_t d = 1; d <= 62; d++) { + computed.at(d) = libzcash::PedersenHash::combine(computed.at(d-1), computed.at(d-1), d-1); + ASSERT_TRUE(emptyroots.empty_root(d) == computed.at(d)); } // Double check that we're testing (at least) all the empty roots we'll use. diff --git a/src/test/data/merkle_roots_empty.json b/src/test/data/merkle_roots_empty.json deleted file mode 100644 index df2674190..000000000 --- a/src/test/data/merkle_roots_empty.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - "0000000000000000000000000000000000000000000000000000000000000000", - "da5698be17b9b46962335799779fbeca8ce5d491c0d26243bafef9ea1837a9d8", - "dc766fab492ccf3d1e49d4f374b5235fa56506aac2224d39f943fcd49202974c", - "3f0a406181105968fdaee30679e3273c66b72bf9a7f5debbf3b5a0a26e359f92", - "26b0052694fc42fdff93e6fb5a71d38c3dd7dc5b6ad710eb048c660233137fab", - "0109ecc0722659ff83450b8f7b8846e67b2859f33c30d9b7acd5bf39cae54e31", - "3f909b8ce3d7ffd8a5b30908f605a03b0db85169558ddc1da7bbbcc9b09fd325", - "40460fa6bc692a06f47521a6725a547c028a6a240d8409f165e63cb54da2d23f", - "8c085674249b43da1b9a31a0e820e81e75f342807b03b6b9e64983217bc2b38e", - "a083450c1ba2a3a7be76fad9d13bc37be4bf83bd3e59fc375a36ba62dc620298", - "1ddddabc2caa2de9eff9e18c8c5a39406d7936e889bc16cfabb144f5c0022682", - "c22d8f0b5e4056e5f318ba22091cc07db5694fbeb5e87ef0d7e2c57ca352359e", - "89a434ae1febd7687eceea21d07f20a2512449d08ce2eee55871cdb9d46c1233", - "7333dbffbd11f09247a2b33a013ec4c4342029d851e22ba485d4461851370c15", - "5dad844ab9466b70f745137195ca221b48f346abd145fb5efc23a8b4ba508022", - "507e0dae81cbfbe457fd370ef1ca4201c2b6401083ddab440e4a038dc1e358c4", - "bdcdb3293188c9807d808267018684cfece07ac35a42c00f2c79b4003825305d", - "bab5800972a16c2c22530c66066d0a5867e987bed21a6d5a450b683cf1cfd709", - "11aa0b4ad29b13b057a31619d6500d636cd735cdd07d811ea265ec4bcbbbd058", - "5145b1b055c2df02b95675e3797b91de1b846d25003c0a803d08900728f2cd6a", - "0323f2850bf3444f4b4c5c09a6057ec7169190f45acb9e46984ab3dfcec4f06a", - "671546e26b1da1af754531e26d8a6a51073a57ddd72dc472efb43fcb257cffff", - "bb23a9bba56de57cb284b0d2b01c642cf79c9a5563f0067a21292412145bd78a", - "f30cc836b9f71b4e7ee3c72b1fd253268af9a27e9d7291a23d02821b21ddfd16", - "58a2753dade103cecbcda50b5ebfce31e12d41d5841dcc95620f7b3d50a1b9a1", - "925e6d474a5d8d3004f29da0dd78d30ae3824ce79dfe4934bb29ec3afaf3d521", - "08f279618616bcdd4eadc9c7a9062691a59b43b07e2c1e237f17bd189cd6a8fe", - "c92b32db42f42e2bf0a59df9055be5c669d3242df45357659b75ae2c27a76f50", - "c0db2a74998c50eb7ba6534f6d410efc27c4bb88acb0222c7906ea28a327b511", - "d7c612c817793191a1e68652121876d6b3bde40f4fa52bc314145ce6e5cdd259", - "b22370106c67a17209f6130bc09f735d83aa2c04fc4fe72ea5d80b216723e7ce", - "9f67d5f664664c901940eee3d02dd5b3e4b92e7b42820c42fc5159e91b41172a", - "ac58cd1388fec290d398f1944b564449a63c815880566bd1d189f7839e3b0c8c", - "5698eae7c8515ed05a70339bdf7c1028e7acca13a4fa97d9538f01ac8d889ae3", - "2d4995770a76fb93314ca74b3524ea1db5688ad0a76183ea17204a8f024a9f3b", - "5e8992c1b072c16e9e28a85358fb5fb6901a81587766dadb7aa0b973ded2f264", - "e95db71e1f7291ba5499461bc715203e29b84bfa4283e3bb7f470a15d0e1584e", - "41f078bd1824c8a4b71964f394aa595084d8eb17b97a3630433af70d10e0eff6", - "a1913fe6b20132312f8c1f00ddd63cec7a03f5f1d7d83492fa284c0b5d6320b0", - "ba9440c4dbfcf55ceb605a5b8990fc11f8ef22870d8d12e130f986491eae84b3", - "49db2d5e22b8015cae4810d75e54014c5469862738e161ec96ec20218718828a", - "d4851fb8431edfbb8b1e85ada6895967c2dac87df344992a05faf1ecf836eec9", - "e4ab9f4470f00cd196d47c75c82e7adaf06fe17e042e3953d93bb5d56d8cd8fb", - "7e4320434849ecb357f1afaaba21a54400ef2d11cff83b937d87fdafa49f8199", - "020adc98d96cfbbcca15fc3aa03760ed286686c35b5d92c7cb64a999b394a854", - "3a26b29fe1acfdd6c6a151bcc3dbcb95a10ebe2f0553f80779569b67b7244e77", - "ec2d0986e6a0ddf43897b2d4f23bb034f538ffe00827f310dc4963f3267f0bfb", - "d48073f8819f81f0358e3fc35a047cc74082ae1cb7ee22fb609c01649342d0e6", - "ad8037601793f172441ecb00dc138d9fc5957125ecc382ec65e36f817dc799fb", - "ca500a5441f36f4df673d6b8ed075d36dae2c7e6481428c70a5a76b7a9bebce8", - "422b6ddd473231dc4d56fe913444ccd56f7c61f747ba57ca946d5fef72d840a0", - "ab41f4ecb7d7089615800e19fcc53b8379ed05ee35c82567095583fd90ff3035", - "bbf7618248354ceb1bc1fc9dbc42c426a4e2c1e0d443c5683a9256c62ecdc26f", - "e50ae71479fc8ec569192a13072e011afc249f471af09500ea39f75d0af856bf", - "e74c0b9220147db2d50a3b58d413775d16c984690be7d90f0bc43d99dba1b689", - "29324a0a48d11657a51ba08b004879bfcfc66a1acb7ce36dfe478d2655484b48", - "88952e3d0ac06cb16b665201122249659a22325e01c870f49e29da6b1757e082", - "cdf879f2435b95af042a3bf7b850f7819246c805285803d67ffbf4f295bed004", - "e005e324200b4f428c62bc3331e695c373607cd0faa9790341fa3ba1ed228bc5", - "354447727aa9a53dd8345b6b6c693443e56ef4aeba13c410179fc8589e7733d5", - "da52dda91f2829c15c0e58d29a95360b86ab30cf0cac8101832a29f38c3185f1", - "c7da7814e228e1144411d78b536092fe920bcdfcc36cf19d1259047b267d58b5", - "aba1f68b6c2b4db6cc06a7340e12313c4b4a4ea6deb17deb3e1e66cd8eacf32b", - "c160ae4f64ab764d864a52ad5e33126c4b5ce105a47deedd75bc70199a5247ef", - "eadf23fc99d514dd8ea204d223e98da988831f9b5d1940274ca520b7fb173d8a", - "5b8e14facac8a7c7a3bfee8bae71f2f7793d3ad5fe3383f93ab6061f2a11bb02" -] diff --git a/src/test/data/merkle_roots_empty_sapling.json b/src/test/data/merkle_roots_empty_sapling.json deleted file mode 100644 index e9646d5c7..000000000 --- a/src/test/data/merkle_roots_empty_sapling.json +++ /dev/null @@ -1,65 +0,0 @@ -[ - "0100000000000000000000000000000000000000000000000000000000000000", - "817de36ab2d57feb077634bca77819c8e0bd298c04f6fed0e6a83cc1356ca155", - "ffe9fc03f18b176c998806439ff0bb8ad193afdb27b2ccbc88856916dd804e34", - "d8283386ef2ef07ebdbb4383c12a739a953a4d6e0d6fb1139a4036d693bfbb6c", - "e110de65c907b9dea4ae0bd83a4b0a51bea175646a64c12b4c9f931b2cb31b49", - "912d82b2c2bca231f71efcf61737fbf0a08befa0416215aeef53e8bb6d23390a", - "8ac9cf9c391e3fd42891d27238a81a8a5c1d3a72b1bcbea8cf44a58ce7389613", - "d6c639ac24b46bd19341c91b13fdcab31581ddaf7f1411336a271f3d0aa52813", - "7b99abdc3730991cc9274727d7d82d28cb794edbc7034b4f0053ff7c4b680444", - "43ff5457f13b926b61df552d4e402ee6dc1463f99a535f9a713439264d5b616b", - "ba49b659fbd0b7334211ea6a9d9df185c757e70aa81da562fb912b84f49bce72", - "4777c8776a3b1e69b73a62fa701fa4f7a6282d9aee2c7a6b82e7937d7081c23c", - "ec677114c27206f5debc1c1ed66f95e2b1885da5b7be3d736b1de98579473048", - "1b77dac4d24fb7258c3c528704c59430b630718bec486421837021cf75dab651", - "bd74b25aacb92378a871bf27d225cfc26baca344a1ea35fdd94510f3d157082c", - "d6acdedf95f608e09fa53fb43dcd0990475726c5131210c9e5caeab97f0e642f", - "1ea6675f9551eeb9dfaaa9247bc9858270d3d3a4c5afa7177a984d5ed1be2451", - "6edb16d01907b759977d7650dad7e3ec049af1a3d875380b697c862c9ec5d51c", - "cd1c8dbf6e3acc7a80439bc4962cf25b9dce7c896f3a5bd70803fc5a0e33cf00", - "6aca8448d8263e547d5ff2950e2ed3839e998d31cbc6ac9fd57bc6002b159216", - "8d5fa43e5a10d11605ac7430ba1f5d81fb1b68d29a640405767749e841527673", - "08eeab0c13abd6069e6310197bf80f9c1ea6de78fd19cbae24d4a520e6cf3023", - "0769557bc682b1bf308646fd0b22e648e8b9e98f57e29f5af40f6edb833e2c49", - "4c6937d78f42685f84b43ad3b7b00f81285662f85c6a68ef11d62ad1a3ee0850", - "fee0e52802cb0c46b1eb4d376c62697f4759f6c8917fa352571202fd778fd712", - "16d6252968971a83da8521d65382e61f0176646d771c91528e3276ee45383e4a", - "d2e1642c9a462229289e5b0e3b7f9008e0301cbb93385ee0e21da2545073cb58", - "a5122c08ff9c161d9ca6fc462073396c7d7d38e8ee48cdb3bea7e2230134ed6a", - "28e7b841dcbc47cceb69d7cb8d94245fb7cb2ba3a7a6bc18f13f945f7dbd6e2a", - "e1f34b034d4a3cd28557e2907ebf990c918f64ecb50a94f01d6fda5ca5c7ef72", - "12935f14b676509b81eb49ef25f39269ed72309238b4c145803544b646dca62d", - "b2eed031d4d6a4f02a097f80b54cc1541d4163c6b6f5971f88b6e41d35c53814", - "fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e", - "252e6798645f5bf114e4b4e90e96182861489840d9b4ccc4c1fb5a46997cee14", - "98b19042f1f7c7dd11ec25ea66b6ff74e08ce11d447ed6f1bfe87e110e331e11", - "d451304799572ba9f42c4dab6b07c703bd2c123ab9d60f2a60f9955854910b6a", - "3ecd5f27acf01bd37a33e4517867ef76474cd83fb31c9208dcef2eedcef36c72", - "26c37da67894a13df8aa4878d2514a4212573b73eccaab16fe4fa660e8fe2707", - "b545ef34485eed30d42b2c295a4a5b680de8a9d5e38345782462c04f09dc6851", - "77fd20b300946765a87f24bd045073729cbd7b66eb8fa140b583faa9d1425801", - "cbaa576b1799b58ff3a6decbba919b0b68d7c893e46fde998768e87e350a0725", - "45fe81b18ca30074d0120d2b1a0d10b3a050933512db8ee34e52473d4f08a267", - "0e60a1f0121f591e551d3ed1865b50a75d7ccff1289df7c44dd465a54317f56a", - "cedfb184dd92a0cbfc11e8be697b476988ed5f39369abdd90c61544988601c0d", - "f362686612649a313ba464437a0cad0e7e3d7e1b4b3743f90e05a2100a495f42", - "7deae5f3bbdeffd3f85271a08b5ec31f16f937964ae708fdff7c13e5a4f3df6b", - "40ccf0fc1eab6d8502bd93dc31342dfd57df5bbb5d70a1bf6b92efc61ec9a258", - "d78025491f1bca8507f64f25872dd02388479a1a225126e40d2fe418b98e0e2c", - "0db7294685c8a0725f15846ea5899ea0e986c2707bd7b412954412f26abf550a", - "b7e290be9555cf75548650da6d47c893aef7f8c6dd2735499495f636590dae0a", - "2dd2532a858c300145a65e351f91be6afeab597c41ef073f50b622d586ff5927", - "972f0c5c6f9aeb0e38bf8319f3a5fcdc8fd8782e4188730cd082d9babc589851", - "001e577b0f4390182b4ae43d329b3aa8835dae1bb79e604b7d2da0e90d060929", - "aa6e70a91ebc54eefce5ffd5b675daf3f1d940a8451fcb01081fa9d4f262436f", - "d77038bf67e631752940231251d7fe85af52dbdd6aab37c7a5ec32b65fe6de03", - "d227a17a7e0cf96dcedd9fc7bce43c6c1d66badd7543a887c8656c547ecfb24f", - "70e8a521951583e53fc0585c707eceda89b7a7d1af41d1a015d797fa76c0f569", - "e485a96855e872fc5090150e2cd24e10591d35166eb0eb30fcdfac93b01d281c", - "e4a19febdf2a86896e41f2cedcf2ae584671802e6a467e8439cab5d61843416b", - "e927838847806a43bd6c6088e39f65b8b3e58b2db5f7ad5643d91e0659a28a2a", - "0bd3a818e83f9cd2ff4f62011a510176ac32f5448e6e154515043c5926d51c6f", - "ce413445e03790498fe72d8e01915e7ff120ae35b3b590d21b7f74dee1830f0d", - "600e6f93e73d7abd4ee0a65cb1b19aa3ecc525689dbf17779658741b95c15a55" -] From ffb8e6747bd4c89e40109987be9246a751ad6f9d Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Sat, 12 Oct 2019 19:06:51 -0600 Subject: [PATCH 3/3] access array element using at() --- src/zcash/IncrementalMerkleTree.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/zcash/IncrementalMerkleTree.cpp b/src/zcash/IncrementalMerkleTree.cpp index 5a7d71537..b8b3cd183 100644 --- a/src/zcash/IncrementalMerkleTree.cpp +++ b/src/zcash/IncrementalMerkleTree.cpp @@ -417,8 +417,7 @@ static const std::array pedersen_empty_roots = { }; PedersenHash PedersenHash::EmptyRoot(size_t depth) { - assert(depth <= sizeof(pedersen_empty_roots)/sizeof(pedersen_empty_roots[0])); - return pedersen_empty_roots[depth]; + return pedersen_empty_roots.at(depth); } SHA256Compress SHA256Compress::combine( @@ -837,8 +836,7 @@ static const std::array sha256_empty_roots = { }; SHA256Compress SHA256Compress::EmptyRoot(size_t depth) { - assert(depth <= sizeof(sha256_empty_roots)/sizeof(sha256_empty_roots[0])); - return sha256_empty_roots[depth]; + return sha256_empty_roots.at(depth); } template