libswarm-ng

C implementation of BMT hasher, Swarmhash and Single Owner Chunk for swarm
git clone git://git.defalsify.org/libswarm-ng.git
Log | Files | Refs | Submodules | README

commit 80d7541a7ec03641a6e2de134903b12142c2bd5d
parent 27e2cd700a61c9b9a3d72936d6e05f53fdd5fb52
Author: nolash <dev@holbrook.no>
Date:   Sun, 12 Sep 2021 12:54:32 +0200

Add comments

Diffstat:
Msrc/bmt.c | 18++----------------
Msrc/bmt_xkcp.c | 1+
2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/bmt.c b/src/bmt.c @@ -1,8 +1,5 @@ #include <string.h> -//#include <XKCP/KeccakHash.h> -//#include <XKCP/KangarooTwelve.h> -//#include <XKCP/SP800-185.h> #include "keccak-tiny.h" #include "endian.h" @@ -13,6 +10,8 @@ #define _KECCAK_RATE 200-64 #define _KECCAK_PADDING 0x01 +// TODO: fork keccak-tiny to expose direct hash method with access to more params +// TODO: abstract hash method to allow alternate use of xkcp or other hash backends extern int hash(uint8_t* out, size_t outlen, const uint8_t* in, size_t inlen, size_t rate, uint8_t delim); static int bmt_rollup(bmt_t *bmt_content) { @@ -23,12 +22,6 @@ static int bmt_rollup(bmt_t *bmt_content) { while (last_target != 0x00) { while (bmt_content->r_ptr < bmt_content->target) { -// Keccak_HashInstance instance; -// if (Keccak_HashInitialize(&instance, 1088, 512, 256, 0x01)) { -// return 1; -// } -// Keccak_HashUpdate(&instance, bmt_content->ptr, _DIGEST_INPUT_SIZE); -// Keccak_HashFinal(&instance, bmt_content->ptr); r = hash(buf, _WORD_SIZE, bmt_content->r_ptr, _DIGEST_INPUT_SIZE, _KECCAK_RATE, _KECCAK_PADDING); if (r != 0) { return 1; @@ -51,13 +44,6 @@ static int bmt_rollup(bmt_t *bmt_content) { } memcpy(bmt_content->buf, buf, _WORD_SIZE); -// Keccak_HashInstance instance; -// if (Keccak_HashInitialize(&instance, 1088, 512, 256, 0x01)) { -// return 1; -// } -// Keccak_HashUpdate(&instance, bmt_content->buf, _DATA_LENGTH_TYPESIZE + _WORD_SIZE); -// Keccak_HashFinal(&instance, bmt_content->buf); - return 0; } diff --git a/src/bmt_xkcp.c b/src/bmt_xkcp.c @@ -11,6 +11,7 @@ #define _ROLLUP_TARGET BLOCK_SIZE + _DATA_LENGTH_TYPESIZE + _WORD_SIZE +// TODO: broken, must be updated to use new pointers static int bmt_rollup(bmt_t *bmt_content) { char *last_target = bmt_content->ptr + _WORD_SIZE;