forked from UNOMP/node-multi-hashing
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlyra2z.c
39 lines (29 loc) · 888 Bytes
/
lyra2z.c
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
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "lyra2z.h"
#include "./sha3/sph_blake.h"
#define _ALIGN(x) __attribute__ ((aligned(x)))
extern uint64_t lyra2z_height;
void lyra2z_hash(const char* input, char* output, uint32_t len)
{
uint32_t _ALIGN(64) hashB[8], hash[8];
sph_blake256_context ctx_blake;
/*
uint64_t height = lyra2z_height;
// initial implementation was pure lyra2 (no blake)
if (height < 100) {
fprintf(stderr, "submit error, height=%u, len=%u\n", (uint32_t) height, len);
memset(hash, 0xff, 32);
return;
}
LYRA2z((void*)hash, 32, (void*)input, len, (void*)input, len, 2, height, 256);
*/
sph_blake256_set_rounds(14);
sph_blake256_init(&ctx_blake);
sph_blake256(&ctx_blake, input, len);
sph_blake256_close(&ctx_blake, hashB);
LYRA2(hash, 32, hashB, 32, hashB, 32, 8, 8, 8);
memcpy(output, hash, 32);
}