diff --git a/crypto/ed25519-donna/ed25519-hash-custom.h b/crypto/ed25519-donna/ed25519-hash-custom.h index b95dc2bc..3f136b92 100644 --- a/crypto/ed25519-donna/ed25519-hash-custom.h +++ b/crypto/ed25519-donna/ed25519-hash-custom.h @@ -9,10 +9,9 @@ void ed25519_hash(uint8_t *hash, const uint8_t *in, size_t inlen); */ -typedef struct ed25519_hash_context_t -{ - void * blake2; -} ed25519_hash_context; +#include + +typedef blake2b_state ed25519_hash_context; void ed25519_hash_init (ed25519_hash_context * ctx); @@ -20,4 +19,4 @@ void ed25519_hash_update (ed25519_hash_context * ctx, uint8_t const * in, size_t void ed25519_hash_final (ed25519_hash_context * ctx, uint8_t * out); -void ed25519_hash (uint8_t * out, uint8_t const * in, size_t inlen); \ No newline at end of file +void ed25519_hash (uint8_t * out, uint8_t const * in, size_t inlen); diff --git a/nano/crypto_lib/interface.cpp b/nano/crypto_lib/interface.cpp index 4c76e9e9..92f1ee37 100644 --- a/nano/crypto_lib/interface.cpp +++ b/nano/crypto_lib/interface.cpp @@ -9,19 +9,17 @@ void ed25519_randombytes_unsafe (void * out, size_t outlen) } void ed25519_hash_init (ed25519_hash_context * ctx) { - ctx->blake2 = new blake2b_state; - blake2b_init (reinterpret_cast (ctx->blake2), 64); + blake2b_init (ctx, 64); } void ed25519_hash_update (ed25519_hash_context * ctx, uint8_t const * in, size_t inlen) { - blake2b_update (reinterpret_cast (ctx->blake2), in, inlen); + blake2b_update (ctx, in, inlen); } void ed25519_hash_final (ed25519_hash_context * ctx, uint8_t * out) { - blake2b_final (reinterpret_cast (ctx->blake2), out, 64); - delete reinterpret_cast (ctx->blake2); + blake2b_final (ctx, out, 64); } void ed25519_hash (uint8_t * out, uint8_t const * in, size_t inlen)