mirror of
https://github.com/luxfi/precompile.git
synced 2026-09-24 00:26:21 +00:00
Git submodules don't work with Go module proxy — go get can't fetch the submodule contents. Vendored the src/ directory from TerenceGe/sr25519-donna directly into sr25519/donna/. Updated unity build paths (donna/src/ → donna/) and CGO CFLAGS. All 8 sr25519 tests pass.
44 lines
1.6 KiB
C
44 lines
1.6 KiB
C
/*
|
|
This is based on the merlin lib from the author (hdevalence) https://github.com/hdevalence/libmerlin
|
|
*/
|
|
|
|
#ifndef MERLIN_H
|
|
#define MERLIN_H
|
|
#define __STDC_WANT_LIB_EXT1__ 1
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
/* XXX can these be made opaque without malloc? */
|
|
|
|
typedef struct merlin_strobe128_ {
|
|
/* XXX endianness */
|
|
union {
|
|
uint64_t state[25];
|
|
uint8_t state_bytes[200];
|
|
};
|
|
uint8_t pos;
|
|
uint8_t pos_begin;
|
|
uint8_t cur_flags;
|
|
} merlin_strobe128;
|
|
|
|
typedef struct merlin_transcript_ {
|
|
merlin_strobe128 sctx;
|
|
} merlin_transcript;
|
|
|
|
typedef struct merlin_rng_ {
|
|
merlin_strobe128 sctx;
|
|
uint8_t finalized;
|
|
} merlin_rng;
|
|
|
|
void merlin_transcript_init(merlin_transcript* mctx, const uint8_t* label, size_t label_len);
|
|
void merlin_transcript_commit_bytes(merlin_transcript* mctx, const uint8_t* label, size_t label_len, const uint8_t* data, size_t data_len);
|
|
void merlin_transcript_challenge_bytes(merlin_transcript* mctx, const uint8_t* label, size_t label_len, uint8_t* buffer, size_t buffer_len);
|
|
void merlin_commit_witness_bytes(merlin_transcript* mctx, uint8_t* dest, size_t dest_len, const uint8_t* label, size_t label_len, const uint8_t* witness, size_t witness_len);
|
|
void merlin_rng_init(merlin_rng* mrng, const merlin_transcript* mctx);
|
|
void merlin_rng_commit_witness_bytes(merlin_rng* mrng, const uint8_t* label, size_t label_len, const uint8_t* witness, size_t witness_len);
|
|
void merlin_rng_finalize(merlin_rng* mrng, const uint8_t entropy[32]);
|
|
void merlin_rng_random_bytes(merlin_rng* mrng, uint8_t* buffer, size_t buffer_len);
|
|
void merlin_rng_wipe(merlin_rng* mrng);
|
|
|
|
#endif
|