Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bitcoin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ BITCOIN_SRC := \
bitcoin/block.c \
bitcoin/chainparams.c \
bitcoin/locktime.c \
bitcoin/groestl.c \
bitcoin/privkey.c \
bitcoin/pubkey.c \
bitcoin/pullpush.c \
bitcoin/script.c \
bitcoin/shadouble.c \
bitcoin/short_channel_id.c \
bitcoin/sph_groestl.c \
bitcoin/signature.c \
bitcoin/tx.c \
bitcoin/varint.c
Expand All @@ -31,6 +33,8 @@ BITCOIN_HEADERS := bitcoin/address.h \
bitcoin/shadouble.h \
bitcoin/short_channel_id.h \
bitcoin/signature.h \
bitcoin/sph_groestl.h \
bitcoin/sph_types.h \
bitcoin/tx.h \
bitcoin/varint.h

Expand Down
4 changes: 3 additions & 1 deletion bitcoin/base58.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#include <libbase58.h>
#include <string.h>

extern void groestl_single_hash(void *, const void * , size_t len);

static bool my_sha256(void *digest, const void *data, size_t datasz)
{
sha256(digest, data, datasz);
groestl_single_hash((void *)&digest, (void *)data, datasz);
return true;
}

Expand Down
71 changes: 71 additions & 0 deletions bitcoin/groestl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <bitcoin/sph_groestl.h>
#include <bitcoin/sph_types.h>
#include <ccan/build_assert/build_assert.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>


void groestlhash(void *, const void *, size_t len);

void groestlhash(void *output, const void *input , size_t len)
{
uint32_t hash[16];
sph_groestl512_context ctx_1,ctx_2;

/*int ii;
printf("result input: ");
for (ii=0; ii < len; ii++)
{
printf ("%.2x",((uint8_t*)input)[ii]);
};
printf ("\n");
*/
sph_groestl512_init(&ctx_1);
sph_groestl512(&ctx_1, input, len);
sph_groestl512_close(&ctx_1, hash);

sph_groestl512_init(&ctx_2);
sph_groestl512(&ctx_2, hash, 64);
sph_groestl512_close(&ctx_2, hash);

memcpy(output, hash, 32);

/*
printf("result output: ");
for (ii=0; ii < 32; ii++)
{
printf ("%.2x",((uint8_t*)output)[ii]);
};
printf ("---\n");
for (ii=0; ii < 32; ii++)
{
printf ("%.2x",((uint8_t*)hash)[ii]);
};
printf ("\n");
*/
}


void groestl_single_hash(void *, const void *, size_t len);


void groestl_single_hash(void *output, const void *input , size_t len)
{
uint32_t hash[16];
sph_groestl512_context ctx;

sph_groestl512_init(&ctx);
sph_groestl512(&ctx, input, len);
sph_groestl512_close(&ctx, hash);
int ii;
printf("groestl ouput: ");
for (ii=0; ii < len; ii++)
{
printf ("%.2x",((uint8_t*)hash)[ii]);
};
memcpy(output, hash, 32);

}


6 changes: 4 additions & 2 deletions bitcoin/shadouble.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
#include <ccan/mem/mem.h>
#include <common/type_to_string.h>

extern void groestlhash(void *, const void * , size_t len);

void sha256_double(struct sha256_double *shadouble, const void *p, size_t len)
{
sha256(&shadouble->sha, memcheck(p, len), len);
sha256(&shadouble->sha, &shadouble->sha, sizeof(shadouble->sha));
groestlhash((void *)&shadouble->sha, (void *)p, len);
}

void sha256_double_done(struct sha256_ctx *shactx, struct sha256_double *res)
{
sha256_done(shactx, &res->sha);
sha256(&res->sha, &res->sha, sizeof(res->sha));
/* FIXME sha256(&res->sha, &res->sha, sizeof(res->sha)); */
}
REGISTER_TYPE_TO_HEXSTR(sha256_double);
Loading