erigontech / erigontech/silkworm

sentry: creating a new secp256k1 context for every operation is not efficient

Open
#2,096 6 comments 0 reactions 0 assignees View on GitHub
performance
Dominant language
C++
Stars
318
Forks
84
PR merge metrics
No merged PRs in 30d

Description

In sentry the secp256k1 is created for every operation which requires it (see the example below). This is not efficient, only single global context is enough.

```cpp
Bytes sign(ByteView data_hash, ByteView private_key) {
SecP256K1Context ctx{/* allow_verify = */ false, /* allow_sign = */ true};
secp256k1_ecdsa_signature signature;
bool ok = ctx.sign(&signature, data_hash, private_key);
if (!ok) {
throw std::runtime_error("ecdsa_signature::sign failed");
}

return ctx.serialize_signature(&signature);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.