randomx.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright (c) 2019 tevador
  3. This file is part of RandomX.
  4. RandomX is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. RandomX is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with RandomX. If not, see<http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef RANDOMX_H
  16. #define RANDOMX_H
  17. #include <stddef.h>
  18. #define RANDOMX_HASH_SIZE 32
  19. #define RANDOMX_DATASET_BLOCKS 33554432UL
  20. typedef enum {
  21. RANDOMX_FLAG_DEFAULT = 0,
  22. RANDOMX_FLAG_LARGE_PAGES = 1,
  23. RANDOMX_FLAG_HARD_AES = 2,
  24. RANDOMX_FLAG_FULL_MEM = 4,
  25. RANDOMX_FLAG_JIT = 8,
  26. } randomx_flags;
  27. typedef struct randomx_dataset randomx_dataset;
  28. typedef struct randomx_cache randomx_cache;
  29. typedef struct randomx_vm randomx_vm;
  30. #if defined(__cplusplus)
  31. extern "C" {
  32. #endif
  33. randomx_cache *randomx_alloc_cache(randomx_flags flags);
  34. void randomx_init_cache(randomx_cache *cache, const void *seed, size_t seedSize);
  35. void randomx_release_cache(randomx_cache* cache);
  36. randomx_dataset *randomx_alloc_dataset(randomx_flags flags);
  37. void randomx_init_dataset(randomx_dataset *dataset, randomx_cache *cache, unsigned long startBlock, unsigned long blockCount);
  38. void randomx_release_dataset(randomx_dataset *dataset);
  39. randomx_vm *randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx_dataset *dataset);
  40. void randomx_vm_set_cache(randomx_vm *machine, randomx_cache* cache);
  41. void randomx_vm_set_dataset(randomx_vm *machine, randomx_dataset *dataset);
  42. void randomx_destroy_vm(randomx_vm *machine);
  43. void randomx_calculate_hash(randomx_vm *machine, const void *input, size_t inputSize, void *output);
  44. #if defined(__cplusplus)
  45. }
  46. #endif
  47. #endif