Undocumented alignment of secp256k1_context #1082

issue Kixunil opened this issue on March 8, 2022
  1. Kixunil commented at 9:41 AM on March 8, 2022: none

    secp256k1_context doesn't have alignment documented but looking at the code it's clearly bigger than 1 since it contains pointers and int. Possibly becuase of lacking documentation Rust bindings used array of bytes (u8 AKA uint8_t) which is very wrong.

  2. Kixunil cross-referenced this on Mar 8, 2022 from issue Clean up once code by Kixunil
  3. elichai commented at 10:15 AM on March 8, 2022: contributor

    I assume you mean the buffer to the preallocated context and not the context itself? if so, the documentation says that it should be aligned to hold "suitably aligned to hold an object of any type.": https://github.com/bitcoin-core/secp256k1/blob/ac83be33d0956faf6b7f61a60ab524ef7d6a473a/include/secp256k1_preallocated.h#L42-L43

    Also, see this discussion: https://github.com/rust-bitcoin/rust-secp256k1/pull/141#discussion_r324882525

  4. Kixunil commented at 11:05 AM on March 8, 2022: none

    Ah, OK, I expected to find this at type not a function. Thanks!

  5. Kixunil closed this on Mar 8, 2022

  6. elichai commented at 11:24 AM on March 8, 2022: contributor

    Note that the secp256k1_context type is opaque and can only be created via function calls to libsecp (either context_create/clone or context_preallocated_create/clone), so either libsecp allocates the memory and takes care of the alignment or the user supplies a buffer to the preallocated API and then they need to make sure it has the alignment that the preallocated API requires.

Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-23 00:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me