No declaration for `secp256k1_xonly_pubkey_load`. #872

issue roconnor-blockstream opened this issue on January 20, 2021
  1. roconnor-blockstream commented at 9:30 PM on January 20, 2021: contributor

    secp256k1_xonly_pubkey_load is used in modules/schnorrsig/main_impl.h but there is declaration for it.

  2. roconnor-blockstream commented at 6:37 PM on January 22, 2021: contributor

    Similarly secp256k1_pubkey_load is used in modules/extrakeys/main_impl.h but there is no declaration for it.

  3. elichai commented at 9:44 AM on September 15, 2021: contributor

    Where should they be declared though? it seems like the only place it makes since is on top of the same main_impl.h file?

    Should static functions even be declared before implementation?

  4. roconnor-blockstream commented at 11:43 AM on September 15, 2021: contributor

    Please correct me if I'm wrong, but my understanding is that functions defined in one file but used in other files ought to have declarations.

  5. elichai commented at 12:06 PM on September 15, 2021: contributor

    @roconnor-blockstream oh right, extrakeys and schnorrsig are separate files that depend on each other.

    I guess this only works because of the order in which they are included in secp256k1.c

  6. sipa commented at 12:17 PM on September 15, 2021: contributor

    Declarations are only necessary when calling a function defined in another compilation unit. Libsecp256k1 is compiled as a single compilation unit (even though some optional parts are called "modules"); everything is directly or indirectly #include'd from secp256k1.c. So only API functions (which can be called from outside the library) strictly speaking need declarations.

    Declarations are also necessary for functions that are called before being defined, which happens e.g. when making mutually recursive calls. I don't think we have any instances of that in the codebase.

    The compiler will warn if a function is called without definition, so I'm pretty sure everything is ok.

    We do have declarations in e.g. field.h and group.h, but those just serve as compiler-checked developer documentation for the implementations and "interface" to that part of the codebase. They're redundant technically speaking.

  7. roconnor-blockstream commented at 1:52 PM on September 15, 2021: contributor

    Right. My understanding is that secp256k1_xonly_pubkey_load and friends ought to have (but isn't required to have) "compiler-checked developer documentation for the implementations and 'interface' to that part of the codebase", and that is what this issue is about. If I'm wrong, then we should close this issue.

  8. real-or-random commented at 2:00 PM on September 15, 2021: contributor

    Hm, that's a valid point. In general, we have only _impl.h files in the modules but no files for the internal API exposed by the modules, and schnorrsig depends on extrakeys for example.

  9. sipa commented at 2:37 PM on September 15, 2021: contributor

    Right. My understanding is that secp256k1_xonly_pubkey_load and friends ought to have (but isn't required to have) "compiler-checked developer documentation for the implementations and 'interface' to that part of the codebase", and that is what this issue is about.

    Oh, yes, I agree with that.


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-14 18:15 UTC

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