Skip to content

Fully static precomputation tables #893

Closed
@real-or-random

Description

@real-or-random

Currently we offer secp256k1_context_no_precomp [1] but it's a "none" context.

If static precomputation (for ecmult_gen contexts) is enabled, we could easily offer a static secp256k1_context_sign. I believe we should do this and additionally offer static precomputation for ecmult contexts. This will make it possible to offer a static secp256k1_context_verify and a fully static secp256k1_context_sign_verify depending on the compilation flags.

I think this is very helpful for embedded targets and is probably much more convenient to use than the prealloc API [2], which requires to users to obtain the size of the context secp256k1_context_preallocated_size() at runtime and deal with manual allocation etc.

[1] Note that the docs can be improved here. They describe the context in terms of internals ("precomputed tables"). We should also describe this in terms of equivalent context flags. The same is true for the name of this thing.

/** A simple secp256k1 context object with no precomputed tables. These are useful for
* type serialization/parsing functions which require a context object to maintain
* API consistency, but currently do not require expensive precomputations or dynamic
* allocations.
*/
SECP256K1_API extern const secp256k1_context *secp256k1_context_no_precomp;

[2] Also with behind language bindings #892, see also @gmaxwell's comment there advocating for a fully static context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions