mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-14 11:26:09 -05:00
![Pieter Wuille](/assets/img/avatar_default.png)
4258c54f4e Merge bitcoin-core/secp256k1#1276: autotools: Don't regenerate Wycheproof header automatically 06c67dea9f autotools: Don't regenerate Wycheproof header automatically 3bab71cf05 Merge bitcoin-core/secp256k1#1268: release cleanup: bump version after 0.3.1 656c6ea8d8 release cleanup: bump version after 0.3.1 346a053d4c Merge bitcoin-core/secp256k1#1269: changelog: Fix link 6a37b2a5ea changelog: Fix link ec98fcedd5 Merge bitcoin-core/secp256k1#1266: release: Prepare for 0.3.1 898e1c676e release: Prepare for 0.3.1 1d9a13fc26 changelog: Remove inconsistent newlines 0e091669a1 changelog: Catch up in preparation of 0.3.1 7b7503dac5 Merge bitcoin-core/secp256k1#1245: tests: Add Wycheproof ECDSA vectors 145078c418 Merge bitcoin-core/secp256k1#1118: Add x-only ecmult_const version with x specified as n/d e5de454609 tests: Add Wycheproof ECDSA vectors 0f8642079b Add exhaustive tests for ecmult_const_xonly 4485926ace Add x-only ecmult_const version for x=n/d a0f4644f7e Merge bitcoin-core/secp256k1#1252: Make position of * in pointer declarations in include/ consistent 4e682626a3 Merge bitcoin-core/secp256k1#1226: Add CMake instructions to release process 2d51a454fc Merge bitcoin-core/secp256k1#1257: ct: Use volatile "trick" in all fe/scalar cmov implementations 4a496a36fb ct: Use volatile "trick" in all fe/scalar cmov implementations 3d1f430f9f Make position of * in pointer declarations in include/ consistent 2bca0a5cbf Merge bitcoin-core/secp256k1#1241: build: Improve `SECP_TRY_APPEND_DEFAULT_CFLAGS` macro afd8b23b27 Merge bitcoin-core/secp256k1#1244: Suppress `-Wunused-parameter` when building for coverage analysis 1d8f367515 Merge bitcoin-core/secp256k1#1250: No need to subtract 1 before doing a right shift 3e43041be6 No need to subtract 1 before doing a right shift 3addb4c1e8 build: Improve `SECP_TRY_APPEND_DEFAULT_CFLAGS` macro 0c07c82834 Add CMake instructions to release process 464a9115b4 Merge bitcoin-core/secp256k1#1242: Set ARM ASM symbol visibility to `hidden` f16a709fd6 Merge bitcoin-core/secp256k1#1247: Apply Checks only in VERIFY mode. 70be3cade5 Merge bitcoin-core/secp256k1#1246: Typo 4ebd82852d Apply Checks only in VERIFY mode. d1e7ca192d Typo 5bb03c2911 Replace `SECP256K1_ECMULT_TABLE_VERIFY` macro by a function 9c8c4f443c Merge bitcoin-core/secp256k1#1238: build: bump CMake minimum requirement to 3.13 0cf2fb91ef Merge bitcoin-core/secp256k1#1243: build: Ensure no optimization when building for coverage analysis fd2a408647 Set ARM ASM symbol visibility to `hidden` 4429a8c218 Suppress `-Wunused-parameter` when building for coverage analysis 8e79c7ed11 build: Ensure no optimization when building for coverage analysis 96dd062511 build: bump CMake minimum requirement to 3.13 427bc3cdcf Merge bitcoin-core/secp256k1#1236: Update comment for secp256k1_modinv32_inv256 647f0a5cb1 Update comment for secp256k1_modinv32_inv256 5658209459 Merge bitcoin-core/secp256k1#1228: release cleanup: bump version after 0.3.0 28e63f7ea7 release cleanup: bump version after 0.3.0 git-subtree-dir: src/secp256k1 git-subtree-split: 4258c54f4ebfc09390168e8a43306c46b315134b
134 lines
5.8 KiB
C
134 lines
5.8 KiB
C
#ifndef SECP256K1_PREALLOCATED_H
|
|
#define SECP256K1_PREALLOCATED_H
|
|
|
|
#include "secp256k1.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* The module provided by this header file is intended for settings in which it
|
|
* is not possible or desirable to rely on dynamic memory allocation. It provides
|
|
* functions for creating, cloning, and destroying secp256k1 context objects in a
|
|
* contiguous fixed-size block of memory provided by the caller.
|
|
*
|
|
* Context objects created by functions in this module can be used like contexts
|
|
* objects created by functions in secp256k1.h, i.e., they can be passed to any
|
|
* API function that expects a context object (see secp256k1.h for details). The
|
|
* only exception is that context objects created by functions in this module
|
|
* must be destroyed using secp256k1_context_preallocated_destroy (in this
|
|
* module) instead of secp256k1_context_destroy (in secp256k1.h).
|
|
*
|
|
* It is guaranteed that functions in this module will not call malloc or its
|
|
* friends realloc, calloc, and free.
|
|
*/
|
|
|
|
/** Determine the memory size of a secp256k1 context object to be created in
|
|
* caller-provided memory.
|
|
*
|
|
* The purpose of this function is to determine how much memory must be provided
|
|
* to secp256k1_context_preallocated_create.
|
|
*
|
|
* Returns: the required size of the caller-provided memory block
|
|
* In: flags: which parts of the context to initialize.
|
|
*/
|
|
SECP256K1_API size_t secp256k1_context_preallocated_size(
|
|
unsigned int flags
|
|
) SECP256K1_WARN_UNUSED_RESULT;
|
|
|
|
/** Create a secp256k1 context object in caller-provided memory.
|
|
*
|
|
* The caller must provide a pointer to a rewritable contiguous block of memory
|
|
* of size at least secp256k1_context_preallocated_size(flags) bytes, suitably
|
|
* aligned to hold an object of any type.
|
|
*
|
|
* The block of memory is exclusively owned by the created context object during
|
|
* the lifetime of this context object, which begins with the call to this
|
|
* function and ends when a call to secp256k1_context_preallocated_destroy
|
|
* (which destroys the context object again) returns. During the lifetime of the
|
|
* context object, the caller is obligated not to access this block of memory,
|
|
* i.e., the caller may not read or write the memory, e.g., by copying the memory
|
|
* contents to a different location or trying to create a second context object
|
|
* in the memory. In simpler words, the prealloc pointer (or any pointer derived
|
|
* from it) should not be used during the lifetime of the context object.
|
|
*
|
|
* Returns: a newly created context object.
|
|
* In: prealloc: a pointer to a rewritable contiguous block of memory of
|
|
* size at least secp256k1_context_preallocated_size(flags)
|
|
* bytes, as detailed above.
|
|
* flags: which parts of the context to initialize.
|
|
*
|
|
* See secp256k1_context_create (in secp256k1.h) for further details.
|
|
*
|
|
* See also secp256k1_context_randomize (in secp256k1.h)
|
|
* and secp256k1_context_preallocated_destroy.
|
|
*/
|
|
SECP256K1_API secp256k1_context *secp256k1_context_preallocated_create(
|
|
void *prealloc,
|
|
unsigned int flags
|
|
) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT;
|
|
|
|
/** Determine the memory size of a secp256k1 context object to be copied into
|
|
* caller-provided memory.
|
|
*
|
|
* Returns: the required size of the caller-provided memory block.
|
|
* In: ctx: an existing context to copy.
|
|
*/
|
|
SECP256K1_API size_t secp256k1_context_preallocated_clone_size(
|
|
const secp256k1_context *ctx
|
|
) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT;
|
|
|
|
/** Copy a secp256k1 context object into caller-provided memory.
|
|
*
|
|
* The caller must provide a pointer to a rewritable contiguous block of memory
|
|
* of size at least secp256k1_context_preallocated_size(flags) bytes, suitably
|
|
* aligned to hold an object of any type.
|
|
*
|
|
* The block of memory is exclusively owned by the created context object during
|
|
* the lifetime of this context object, see the description of
|
|
* secp256k1_context_preallocated_create for details.
|
|
*
|
|
* Cloning secp256k1_context_static is not possible, and should not be emulated by
|
|
* the caller (e.g., using memcpy). Create a new context instead.
|
|
*
|
|
* Returns: a newly created context object.
|
|
* Args: ctx: an existing context to copy (not secp256k1_context_static).
|
|
* In: prealloc: a pointer to a rewritable contiguous block of memory of
|
|
* size at least secp256k1_context_preallocated_size(flags)
|
|
* bytes, as detailed above.
|
|
*/
|
|
SECP256K1_API secp256k1_context *secp256k1_context_preallocated_clone(
|
|
const secp256k1_context *ctx,
|
|
void *prealloc
|
|
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_WARN_UNUSED_RESULT;
|
|
|
|
/** Destroy a secp256k1 context object that has been created in
|
|
* caller-provided memory.
|
|
*
|
|
* The context pointer may not be used afterwards.
|
|
*
|
|
* The context to destroy must have been created using
|
|
* secp256k1_context_preallocated_create or secp256k1_context_preallocated_clone.
|
|
* If the context has instead been created using secp256k1_context_create or
|
|
* secp256k1_context_clone, the behaviour is undefined. In that case,
|
|
* secp256k1_context_destroy must be used instead.
|
|
*
|
|
* If required, it is the responsibility of the caller to deallocate the block
|
|
* of memory properly after this function returns, e.g., by calling free on the
|
|
* preallocated pointer given to secp256k1_context_preallocated_create or
|
|
* secp256k1_context_preallocated_clone.
|
|
*
|
|
* Args: ctx: an existing context to destroy, constructed using
|
|
* secp256k1_context_preallocated_create or
|
|
* secp256k1_context_preallocated_clone
|
|
* (i.e., not secp256k1_context_static).
|
|
*/
|
|
SECP256K1_API void secp256k1_context_preallocated_destroy(
|
|
secp256k1_context *ctx
|
|
) SECP256K1_ARG_NONNULL(1);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* SECP256K1_PREALLOCATED_H */
|