Merge branch 'master' into sync-7262adb4

This commit is contained in:
DarkWindman
2026-04-01 17:29:57 +03:00
93 changed files with 13380 additions and 124 deletions

View File

@@ -1,5 +1,5 @@
/***********************************************************************
* Copyright (c) 2013-2015 Pieter Wuille *
* Copyright (c) 2013-2015 Pieter Wuille, Gregory Maxwell *
* Distributed under the MIT software license, see the accompanying *
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
***********************************************************************/
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "testrand.h"
#include "hash.h"
@@ -118,6 +119,23 @@ static void testrand256_test(unsigned char *b32) {
testrand_bytes_test(b32, 32);
}
SECP256K1_INLINE static int64_t testrandi64(uint64_t min, uint64_t max) {
uint64_t range;
uint64_t r;
uint64_t clz;
VERIFY_CHECK(max >= min);
if (max == min) {
return min;
}
range = max - min;
clz = secp256k1_clz64_var(range);
do {
r = ((uint64_t)testrand32() << 32) | testrand32();
r >>= clz;
} while (r > range);
return min + (int64_t)r;
}
static void testrand_flip(unsigned char *b, size_t len) {
b[testrand_int(len)] ^= (1 << testrand_bits(3));
}