pool/stratum/algos/argon2d-dyn.c
Amir Abrams cc456814c5 Add Dynamic Argon2d algorithm to YIIMP Stratum Pool (#301)
- Use dynode instead of masternode for Dynamic
- Updates Argon2d hash library (https://github.com/P-H-C/phc-winner-argon2)
- Adds argon2d-dyn.conf sample template file
- Code contributed by @BigEvilSoloMiner from Discord.
- testing and contributions by @R3D5H1RT from Discord
- testing and support by @InsaneITGeek from Discord.
- Dynamic test stratum pool: https://testpool.dualityblocks.com
2018-09-04 10:30:06 +02:00

43 lines
No EOL
1.4 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "sysendian.h"
#include "ar2/argon2.h"
#include "ar2/core.h"
static const size_t INPUT_BYTES = 80; // Lenth of a block header in bytes. Input Length = Salt Length (salt = input)
static const size_t OUTPUT_BYTES = 32; // Length of output needed for a 256-bit hash
static const unsigned int DEFAULT_ARGON2_FLAG = 2; //Same as ARGON2_DEFAULT_FLAGS
void argon2d_call(const void *input, void *output)
{
argon2_context context;
context.out = (uint8_t *)output;
context.outlen = (uint32_t)OUTPUT_BYTES;
context.pwd = (uint8_t *)input;
context.pwdlen = (uint32_t)INPUT_BYTES;
context.salt = (uint8_t *)input; //salt = input
context.saltlen = (uint32_t)INPUT_BYTES;
context.secret = NULL;
context.secretlen = 0;
context.ad = NULL;
context.adlen = 0;
context.allocate_cbk = NULL;
context.free_cbk = NULL;
context.flags = DEFAULT_ARGON2_FLAG; // = ARGON2_DEFAULT_FLAGS
// main configurable Argon2 hash parameters
context.m_cost = 500; // Memory in KiB (512KB)
context.lanes = 8; // Degree of Parallelism
context.threads = 1; // Threads
context.t_cost = 2; // Iterations
argon2_ctx(&context, Argon2_d);
}
void argon2d_dyn_hash(const unsigned char* input, unsigned char* output, unsigned int len)
{
argon2d_call(input, output);
}