Skip to content

Conversation

@jonasnick
Copy link
Contributor

This is a draft because I'm not sure about the cleanest way to implement it.

@real-or-random
Copy link
Contributor

This is a draft because I'm not sure about the cleanest way to implement it.

The current approach looks clean. What other approaches do you have in mind?

struct secp256k1_strauss_point_state {
int wnaf_na_1[129];
int wnaf_na_lam[129];
int8_t wnaf_na_1[129];
Copy link
Contributor

@real-or-random real-or-random Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int8_t wnaf_na_1[129];
int_least8_t wnaf_na_1[129];

This is technically better to retain support for platforms that don't offer int8_t. I don't think there are any relevant platforms of that kind, but why not... 🤷

edit: Now that I think about it again, a platform that does not offer int8_t will most likely one for which CHAR_BITS != 8. And then it's neither relevant nor it's likely to offer int32_t or int64_t which we need anyway. So I guess there's no difference between int8_t and int_least8_t.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically better to retain support for platforms that don't offer int8_t.

int8_t is already used in src/assumptions.h.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my x86_64 system, this PR reduces the memory allocated on the scratch space from 2224 bytes to 1452 bytes per point.

Please ping me once it’s undrafted.

@jonasnick
Copy link
Contributor Author

The current approach requires a temporary array int wnaf_tmp[256]; to provide to secp256k1_ecmult_wnaf which looks unclean. The alternatives are

  1. copy almost all of secp256k1_ecmult_wnaf into secp256k1_ecmult_wnaf_small, or
  2. remove secp256k1_ecmult_wnaf_small and write an secp256k1_ecmult macro.

Both options seem to be worse.

@hebasto
Copy link
Member

hebasto commented Oct 27, 2025

The current approach requires a temporary array int wnaf_tmp[256]; to provide to secp256k1_ecmult_wnaf which looks unclean. The alternatives are

  1. copy almost all of secp256k1_ecmult_wnaf into secp256k1_ecmult_wnaf_small, or

  2. remove secp256k1_ecmult_wnaf_small and write an secp256k1_ecmult macro.

Both options seem to be worse.

I might suggest a third option: hebasto@5c0d6ee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants