paritytech / libsecp256k1

Pure Rust Implementation of secp256k1.
Apache License 2.0
176 stars 84 forks source link

Make static context a feature and allow dynamic context generation #41

Closed sorpaas closed 4 years ago

sorpaas commented 4 years ago

This changes the static contexts to be a feature that can be enabled or disabled, and allow contexts to be dynamically generated. By disabling static contexts, users accomplish much smaller binary size, but the trade-off is then that contexts must be generated dynamically (which is not a cheap operation).

dvdplm commented 4 years ago

Can you ELI5 what "static|dynamic context" means in this context?

sorpaas commented 4 years ago

@dvdplm It's the pre-computed table used to accelerate various calculations. Previously we only allow storing the table as static variables directly in the library. This PR allows disabling those variables (to reduce binary size, if needed) and generate the tables dynamically.

dvdplm commented 4 years ago

This PR allows disabling those variables (to reduce binary size, if needed) and generate the tables dynamically.

How much bigger is the static vs dynamic build? How much does the table generation cost under normal use?

I think it'd be good to get some of this info into the README to help users decide. :)

sorpaas commented 4 years ago

How much bigger is the static vs dynamic build? How much does the table generation cost under normal use?

It is reported to be quite significant -- around 1mb or so. I knew some users were discouraged previously from using libsecp256k1 just because of this. I don't have the exact numbers in hand but we can get it later. :)

dvdplm commented 4 years ago

we can get it later

Added https://github.com/paritytech/libsecp256k1/issues/46