Monero
Loading...
Searching...
No Matches
randomx.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018-2019, tevador <tevador@gmail.com>
3
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the copyright holder nor the
14 names of its contributors may be used to endorse or promote products
15 derived from this software without specific prior written permission.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#ifndef RANDOMX_H
30#define RANDOMX_H
31
32#include <stddef.h>
33#include <stdint.h>
34
35#define RANDOMX_HASH_SIZE 32
36#define RANDOMX_DATASET_ITEM_SIZE 64
37
38#ifndef RANDOMX_EXPORT
39#define RANDOMX_EXPORT
40#endif
41
53
56typedef struct randomx_vm randomx_vm;
57
58
59#if defined(__cplusplus)
60
61#ifdef __cpp_constexpr
62#define CONSTEXPR constexpr
63#else
64#define CONSTEXPR
65#endif
66
67inline CONSTEXPR randomx_flags operator |(randomx_flags a, randomx_flags b) {
68 return static_cast<randomx_flags>(static_cast<int>(a) | static_cast<int>(b));
69}
71 return static_cast<randomx_flags>(static_cast<int>(a) & static_cast<int>(b));
72}
73inline randomx_flags& operator |=(randomx_flags& a, randomx_flags b) {
74 return a = a | b;
75}
76
77extern "C" {
78#endif
79
90
111
120RANDOMX_EXPORT void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize);
121
128
139
146
158RANDOMX_EXPORT void randomx_init_dataset(randomx_dataset *dataset, randomx_cache *cache, unsigned long startItem, unsigned long itemCount);
159
169
176
203
214
223
230
240RANDOMX_EXPORT void randomx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output);
241
259RANDOMX_EXPORT void randomx_calculate_hash_first(randomx_vm* machine, const void* input, size_t inputSize);
260RANDOMX_EXPORT void randomx_calculate_hash_next(randomx_vm* machine, const void* nextInput, size_t nextInputSize, void* output);
261RANDOMX_EXPORT void randomx_calculate_hash_last(randomx_vm* machine, void* output);
262
272RANDOMX_EXPORT void randomx_calculate_commitment(const void* input, size_t inputSize, const void* hash_in, void* com_out);
273
274#if defined(__cplusplus)
275}
276#endif
277
278#endif
Archiver & operator&(Archiver &ar, Student &s)
Definition archivertest.cpp:21
cryptonote::block b
Definition block.cpp:40
Definition virtual_machine.hpp:36
const char * key
Definition hmac_keccak.cpp:40
static int flags
Definition mdb_load.c:31
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124
RANDOMX_EXPORT void randomx_release_cache(randomx_cache *cache)
Definition randomx.cpp:141
RANDOMX_EXPORT void randomx_calculate_commitment(const void *input, size_t inputSize, const void *hash_in, void *com_out)
Definition randomx.cpp:421
randomx_flags
Definition randomx.h:42
@ RANDOMX_FLAG_ARGON2_SSSE3
Definition randomx.h:49
@ RANDOMX_FLAG_ARGON2_AVX2
Definition randomx.h:50
@ RANDOMX_FLAG_ARGON2
Definition randomx.h:51
@ RANDOMX_FLAG_SECURE
Definition randomx.h:48
@ RANDOMX_FLAG_FULL_MEM
Definition randomx.h:46
@ RANDOMX_FLAG_LARGE_PAGES
Definition randomx.h:44
@ RANDOMX_FLAG_JIT
Definition randomx.h:47
@ RANDOMX_FLAG_HARD_AES
Definition randomx.h:45
@ RANDOMX_FLAG_DEFAULT
Definition randomx.h:43
#define RANDOMX_EXPORT
Definition randomx.h:39
RANDOMX_EXPORT unsigned long randomx_dataset_item_count(void)
Definition randomx.cpp:183
RANDOMX_EXPORT randomx_vm * randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx_dataset *dataset)
Definition randomx.cpp:206
RANDOMX_EXPORT void randomx_calculate_hash_last(randomx_vm *machine, void *output)
Definition randomx.cpp:411
RANDOMX_EXPORT void randomx_destroy_vm(randomx_vm *machine)
Definition randomx.cpp:356
RANDOMX_EXPORT randomx_dataset * randomx_alloc_dataset(randomx_flags flags)
Definition randomx.cpp:147
RANDOMX_EXPORT void * randomx_get_dataset_memory(randomx_dataset *dataset)
Definition randomx.cpp:195
RANDOMX_EXPORT randomx_cache * randomx_alloc_cache(randomx_flags flags)
Definition randomx.cpp:69
RANDOMX_EXPORT void randomx_calculate_hash_next(randomx_vm *machine, const void *nextInput, size_t nextInputSize, void *output)
Definition randomx.cpp:398
RANDOMX_EXPORT randomx_flags randomx_get_flags(void)
Definition randomx.cpp:49
RANDOMX_EXPORT void randomx_vm_set_dataset(randomx_vm *machine, randomx_dataset *dataset)
Definition randomx.cpp:350
RANDOMX_EXPORT void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize)
Definition randomx.cpp:130
RANDOMX_EXPORT void randomx_vm_set_cache(randomx_vm *machine, randomx_cache *cache)
Definition randomx.cpp:341
RANDOMX_EXPORT void randomx_init_dataset(randomx_dataset *dataset, randomx_cache *cache, unsigned long startItem, unsigned long itemCount)
Definition randomx.cpp:187
RANDOMX_EXPORT void randomx_release_dataset(randomx_dataset *dataset)
Definition randomx.cpp:200
RANDOMX_EXPORT void randomx_calculate_hash_first(randomx_vm *machine, const void *input, size_t inputSize)
Definition randomx.cpp:393
RANDOMX_EXPORT void randomx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output)
Definition randomx.cpp:361
Definition dataset.hpp:46
Definition dataset.hpp:40
randomx_cache * cache
Definition tests.cpp:19