forked from peterdemon/opencl-cryptonight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cryptonight.h
44 lines (37 loc) · 1.44 KB
/
cryptonight.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef __CRYPTONIGHT_H_INCLUDED
#define __CRYPTONIGHT_H_INCLUDED
#include "crypto/hash-ops.h"
#include "miner.h"
#define MEMORY (1 << 21) /* 2 MiB */
#define ITER (1 << 20)
#define AES_BLOCK_SIZE 16
#define AES_KEY_SIZE 32 /*16*/
#define INIT_SIZE_BLK 8
#define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) // 128
#pragma pack(push, 1)
union cn_slow_hash_state {
union hash_state hs;
struct {
uint8_t k[64];
uint8_t init[INIT_SIZE_BYTE];
};
};
#pragma pack(pop)
struct cryptonight_ctx {
uint8_t long_state[MEMORY] __attribute((aligned(16)));
union cn_slow_hash_state state;
uint8_t text[INIT_SIZE_BYTE] __attribute((aligned(16)));
uint64_t a[AES_BLOCK_SIZE >> 3] __attribute__((aligned(16)));
uint64_t b[AES_BLOCK_SIZE >> 3] __attribute__((aligned(16)));
uint8_t c[AES_BLOCK_SIZE] __attribute__((aligned(16)));
uint8_t AESKey1[256];
uint8_t AESKey2[256];
};
void do_blake_hash(const void* input, size_t len, char* output);
void do_groestl_hash(const void* input, size_t len, char* output);
void do_jh_hash(const void* input, size_t len, char* output);
void do_skein_hash(const void* input, size_t len, char* output);
void xor_blocks_dst(const uint8_t *restrict a, const uint8_t *restrict b, uint8_t *restrict dst);
void cryptonight_hash_ctx(void* output, const void* input, struct cryptonight_ctx* ctx);
extern void (* const extra_hashes[4])(const void *, size_t, char *);
#endif