75 lines
1.8 KiB
C
75 lines
1.8 KiB
C
#ifndef SKALACOIN_AUTOLYKOS2_H
|
|
#define SKALACOIN_AUTOLYKOS2_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <constants.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct Autolykos2Context Autolykos2Context;
|
|
|
|
extern uint64_t g_autolykos2_sleepBetweenHashOperationsMicroseconds;
|
|
|
|
Autolykos2Context* Autolykos2_Create(void);
|
|
void Autolykos2_Destroy(Autolykos2Context* ctx);
|
|
|
|
bool Autolykos2_DagAllocate(Autolykos2Context* ctx, size_t bytes);
|
|
bool Autolykos2_DagAppend(Autolykos2Context* ctx, const uint8_t* data, size_t len);
|
|
bool Autolykos2_DagGenerate(Autolykos2Context* ctx, const uint8_t seed32[32]);
|
|
void Autolykos2_DagClear(Autolykos2Context* ctx);
|
|
size_t Autolykos2_DagSize(const Autolykos2Context* ctx);
|
|
|
|
bool Autolykos2_Hash(
|
|
Autolykos2Context* ctx,
|
|
const uint8_t* message,
|
|
size_t messageLen,
|
|
uint64_t nonce,
|
|
uint64_t height,
|
|
uint8_t outHash[32]
|
|
);
|
|
|
|
// Derives the DAG lanes it needs straight from the epoch seed, so it needs no DAG allocation and
|
|
// stays correct for any height regardless of which epoch a DAG happens to be built for. Produces
|
|
// exactly the same hash as Autolykos2_Hash against a DAG generated from the same seed and size.
|
|
bool Autolykos2_LightHashAtHeight(
|
|
const uint8_t seed32[32],
|
|
const uint8_t* message,
|
|
size_t messageLen,
|
|
uint64_t nonce,
|
|
uint64_t height,
|
|
size_t dagBytes,
|
|
uint8_t out[32]
|
|
);
|
|
|
|
bool Autolykos2_CheckTarget(
|
|
Autolykos2Context* ctx,
|
|
const uint8_t message32[32],
|
|
uint64_t nonce,
|
|
uint64_t height,
|
|
const uint8_t target32[32],
|
|
uint8_t outHash[32]
|
|
);
|
|
|
|
bool Autolykos2_FindNonceSingleCore(
|
|
Autolykos2Context* ctx,
|
|
const uint8_t message32[32],
|
|
uint64_t height,
|
|
const uint8_t target32[32],
|
|
uint64_t startNonce,
|
|
uint64_t maxIterations,
|
|
uint64_t* outNonce,
|
|
uint8_t outHash[32]
|
|
);
|
|
|
|
void Autolykos2_SetSleepBetweenHashOperations(uint64_t sleepMicroseconds);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|