add resizeable scratch space API

Alignment support by Pieter Wuille.
This commit is contained in:
Andrew Poelstra
2017-07-22 18:03:17 +00:00
committed by Jonas Nick
parent 6ad5cdb42a
commit 548de42ecf
7 changed files with 205 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
#include "ecdsa_impl.h"
#include "eckey_impl.h"
#include "hash_impl.h"
#include "scratch_impl.h"
#define ARG_CHECK(cond) do { \
if (EXPECT(!(cond), 0)) { \
@@ -114,6 +115,17 @@ void secp256k1_context_set_error_callback(secp256k1_context* ctx, void (*fun)(co
ctx->error_callback.data = data;
}
secp256k1_scratch_space* secp256k1_scratch_space_create(const secp256k1_context* ctx, size_t init_size, size_t max_size) {
VERIFY_CHECK(ctx != NULL);
ARG_CHECK(max_size >= init_size);
return secp256k1_scratch_create(&ctx->error_callback, init_size, max_size);
}
void secp256k1_scratch_space_destroy(secp256k1_scratch_space* scratch) {
secp256k1_scratch_destroy(scratch);
}
static int secp256k1_pubkey_load(const secp256k1_context* ctx, secp256k1_ge* ge, const secp256k1_pubkey* pubkey) {
if (sizeof(secp256k1_ge_storage) == 64) {
/* When the secp256k1_ge_storage type is exactly 64 byte, use its