| 1896 | } |
| 1897 | |
| 1898 | uint256 ComputeTaprootMerkleRoot(std::span<const unsigned char> control, const uint256& tapleaf_hash) |
| 1899 | { |
| 1900 | assert(control.size() >= TAPROOT_CONTROL_BASE_SIZE); |
| 1901 | assert(control.size() <= TAPROOT_CONTROL_MAX_SIZE); |
| 1902 | assert((control.size() - TAPROOT_CONTROL_BASE_SIZE) % TAPROOT_CONTROL_NODE_SIZE == 0); |
| 1903 | |
| 1904 | const int path_len = (control.size() - TAPROOT_CONTROL_BASE_SIZE) / TAPROOT_CONTROL_NODE_SIZE; |
| 1905 | uint256 k = tapleaf_hash; |
| 1906 | for (int i = 0; i < path_len; ++i) { |
| 1907 | std::span node{std::span{control}.subspan(TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * i, TAPROOT_CONTROL_NODE_SIZE)}; |
| 1908 | k = ComputeTapbranchHash(k, node); |
| 1909 | } |
| 1910 | return k; |
| 1911 | } |
| 1912 | |
| 1913 | static bool VerifyTaprootCommitment(const std::vector<unsigned char>& control, const std::vector<unsigned char>& program, const uint256& tapleaf_hash) |
| 1914 | { |
no test coverage detected