Skip to content

[API Hardening] Decide and document zero / point-at-infinity handling at every API boundary #112

@tesseract-ripple

Description

@tesseract-ripple

Severity: Informational; clarity / future-defense.
Source: TOB May 2026 revision, Appendix D — "Malformed scalar
and point edge cases" (pp. 63-64).

Problem

libsecp256k1's seckey_* helpers reject zero by design (because
zero is not a valid ECDSA secret key), but the CMPT protocol has
mathematical scalars that can legitimately be zero (amounts,
balances, response scalars in negligible-probability cases) and
mathematical points that can legitimately be the identity
(homomorphic differences, MSM intermediates). Mixing the two
conventions has caused several historical bugs in this codebase
(#37/#38, #39, #41, #51).

Each API boundary should make an explicit, documented choice
between three options:

Recommended change

For every API that can be reached with zero scalar input or
identity point output, document the decision in the doxygen, add
tests that cover both the "zero is valid" and "zero is rejected"
cases, and ensure internal helpers don't silently fail when
encountering it.

TOB-specific call sites to cover (per Appendix D p. 63-64):

Acceptance

  • Every API boundary listed above has a doxygen sentence stating
    the zero / identity handling decision.
  • Each has at least one test case exercising the zero / identity
    input or output explicitly.
  • The current code's behavior is preserved; this is a
    documentation + test-coverage issue, not a behavior change
    (except for any specific bugs found during the sweep).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions