tests: refactor: drop secp256k1_ prefix from testrand.h functions

The rename was done with the following command:

$ sed -i 's/secp256k1_testrand/testrand/g' $(git grep -l secp256k1_testrand)
This commit is contained in:
Sebastian Falbesoner
2024-05-27 03:08:07 +02:00
parent 0ee7453a99
commit e73f6f8fd9
10 changed files with 176 additions and 176 deletions

View File

@@ -17,7 +17,7 @@
static uint64_t secp256k1_test_state[4];
SECP256K1_INLINE static void secp256k1_testrand_seed(const unsigned char *seed16) {
SECP256K1_INLINE static void testrand_seed(const unsigned char *seed16) {
static const unsigned char PREFIX[19] = "secp256k1 test init";
unsigned char out32[32];
secp256k1_sha256 hash;
@@ -40,7 +40,7 @@ SECP256K1_INLINE static uint64_t rotl(const uint64_t x, int k) {
return (x << k) | (x >> (64 - k));
}
SECP256K1_INLINE static uint64_t secp256k1_testrand64(void) {
SECP256K1_INLINE static uint64_t testrand64(void) {
/* Test-only Xoshiro256++ RNG. See https://prng.di.unimi.it/ */
const uint64_t result = rotl(secp256k1_test_state[0] + secp256k1_test_state[3], 23) + secp256k1_test_state[0];
const uint64_t t = secp256k1_test_state[1] << 17;
@@ -53,16 +53,16 @@ SECP256K1_INLINE static uint64_t secp256k1_testrand64(void) {
return result;
}
SECP256K1_INLINE static uint64_t secp256k1_testrand_bits(int bits) {
SECP256K1_INLINE static uint64_t testrand_bits(int bits) {
if (bits == 0) return 0;
return secp256k1_testrand64() >> (64 - bits);
return testrand64() >> (64 - bits);
}
SECP256K1_INLINE static uint32_t secp256k1_testrand32(void) {
return secp256k1_testrand64() >> 32;
SECP256K1_INLINE static uint32_t testrand32(void) {
return testrand64() >> 32;
}
static uint32_t secp256k1_testrand_int(uint32_t range) {
static uint32_t testrand_int(uint32_t range) {
uint32_t mask = 0;
uint32_t range_copy;
/* Reduce range by 1, changing its meaning to "maximum value". */
@@ -76,15 +76,15 @@ static uint32_t secp256k1_testrand_int(uint32_t range) {
}
/* Generation loop. */
while (1) {
uint32_t val = secp256k1_testrand64() & mask;
uint32_t val = testrand64() & mask;
if (val <= range) return val;
}
}
static void secp256k1_testrand256(unsigned char *b32) {
static void testrand256(unsigned char *b32) {
int i;
for (i = 0; i < 4; ++i) {
uint64_t val = secp256k1_testrand64();
uint64_t val = testrand64();
b32[0] = val;
b32[1] = val >> 8;
b32[2] = val >> 16;
@@ -97,14 +97,14 @@ static void secp256k1_testrand256(unsigned char *b32) {
}
}
static void secp256k1_testrand_bytes_test(unsigned char *bytes, size_t len) {
static void testrand_bytes_test(unsigned char *bytes, size_t len) {
size_t bits = 0;
memset(bytes, 0, len);
while (bits < len * 8) {
int now;
uint32_t val;
now = 1 + (secp256k1_testrand_bits(6) * secp256k1_testrand_bits(5) + 16) / 31;
val = secp256k1_testrand_bits(1);
now = 1 + (testrand_bits(6) * testrand_bits(5) + 16) / 31;
val = testrand_bits(1);
while (now > 0 && bits < len * 8) {
bytes[bits / 8] |= val << (bits % 8);
now--;
@@ -113,15 +113,15 @@ static void secp256k1_testrand_bytes_test(unsigned char *bytes, size_t len) {
}
}
static void secp256k1_testrand256_test(unsigned char *b32) {
secp256k1_testrand_bytes_test(b32, 32);
static void testrand256_test(unsigned char *b32) {
testrand_bytes_test(b32, 32);
}
static void secp256k1_testrand_flip(unsigned char *b, size_t len) {
b[secp256k1_testrand_int(len)] ^= (1 << secp256k1_testrand_bits(3));
static void testrand_flip(unsigned char *b, size_t len) {
b[testrand_int(len)] ^= (1 << testrand_bits(3));
}
static void secp256k1_testrand_init(const char* hexseed) {
static void testrand_init(const char* hexseed) {
unsigned char seed16[16] = {0};
if (hexseed && strlen(hexseed) != 0) {
int pos = 0;
@@ -155,12 +155,12 @@ static void secp256k1_testrand_init(const char* hexseed) {
}
printf("random seed = %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", seed16[0], seed16[1], seed16[2], seed16[3], seed16[4], seed16[5], seed16[6], seed16[7], seed16[8], seed16[9], seed16[10], seed16[11], seed16[12], seed16[13], seed16[14], seed16[15]);
secp256k1_testrand_seed(seed16);
testrand_seed(seed16);
}
static void secp256k1_testrand_finish(void) {
static void testrand_finish(void) {
unsigned char run32[32];
secp256k1_testrand256(run32);
testrand256(run32);
printf("random run = %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", run32[0], run32[1], run32[2], run32[3], run32[4], run32[5], run32[6], run32[7], run32[8], run32[9], run32[10], run32[11], run32[12], run32[13], run32[14], run32[15]);
}