Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
src
secp256k1
src
selftest.h
Go to the documentation of this file.
1
/***********************************************************************
2
* Copyright (c) 2020 Pieter Wuille *
3
* Distributed under the MIT software license, see the accompanying *
4
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
5
***********************************************************************/
6
7
#ifndef SECP256K1_SELFTEST_H
8
#define SECP256K1_SELFTEST_H
9
10
#include "
hash.h
"
11
12
#include <
string.h
>
13
14
static
int
secp256k1_selftest_sha256
(
void
) {
15
static
const
char
*
input63
=
"For this sample, this 63-byte string will be used as input data"
;
16
static
const
unsigned
char
output32
[32] = {
17
0xf0, 0x8a, 0x78, 0xcb, 0xba, 0xee, 0x08, 0x2b, 0x05, 0x2a, 0xe0, 0x70, 0x8f, 0x32, 0xfa, 0x1e,
18
0x50, 0xc5, 0xc4, 0x21, 0xaa, 0x77, 0x2b, 0xa5, 0xdb, 0xb4, 0x06, 0xa2, 0xea, 0x6b, 0xe3, 0x42,
19
};
20
unsigned
char
out[32];
21
secp256k1_sha256
hasher;
22
secp256k1_sha256_initialize
(&hasher);
23
secp256k1_sha256_write
(&hasher, (
const
unsigned
char
*)
input63
, 63);
24
secp256k1_sha256_finalize
(&hasher, out);
25
return
secp256k1_memcmp_var
(out,
output32
, 32) == 0;
26
}
27
28
static
int
secp256k1_selftest
(
void
) {
29
return
secp256k1_selftest_sha256
();
30
}
31
32
#endif
/* SECP256K1_SELFTEST_H */
GetRand
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition
random.h:85
hash.h
secp256k1_sha256_initialize
static void secp256k1_sha256_initialize(secp256k1_sha256 *hash)
secp256k1_sha256_finalize
static void secp256k1_sha256_finalize(secp256k1_sha256 *hash, unsigned char *out32)
secp256k1_sha256_write
static void secp256k1_sha256_write(secp256k1_sha256 *hash, const unsigned char *data, size_t size)
secp256k1_memcmp_var
static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2, size_t n)
Semantics like memcmp.
Definition
util.h:224
secp256k1_selftest
static int secp256k1_selftest(void)
Definition
selftest.h:28
secp256k1_selftest_sha256
static int secp256k1_selftest_sha256(void)
Definition
selftest.h:14
string.h
secp256k1_sha256
Definition
hash.h:13
Generated on Sat Nov 23 2024 02:38:01 for Bitcoin ABC by
1.9.8