Skip to content

Use fixed-size spans for XEd25519 inputs - #114

Merged
jagerman merged 1 commit into
session-foundation:devfrom
Ap4sh:fix-xed25519-input-sizes
Aug 6, 2026
Merged

Use fixed-size spans for XEd25519 inputs#114
jagerman merged 1 commit into
session-foundation:devfrom
Ap4sh:fix-xed25519-input-sizes

Conversation

@Ap4sh

@Ap4sh Ap4sh commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

summary

the binary C++ XEd25519 API now uses fixed-size spans for keys and signatures, making invalid input sizes a compile-time error

the dynamic string overloads validate sizes before converting to those fixed spans, and the affected blinding and group-key call sites now pass explicitly sized views or fixed arrays

tests

  • ./utils/format.sh verify
  • release build with cmake --build build-clean --target testAll --parallel 2
  • ./build-clean/tests/testAll "[xed25519]"
  • ./build-clean/tests/testAll "*blinded*"
  • ./build-clean/tests/testAll "Group Keys*"
  • ./build-clean/tests/testAll

@Ap4sh
Ap4sh marked this pull request as ready for review August 5, 2026 18:48
@jagerman

jagerman commented Aug 5, 2026

Copy link
Copy Markdown
Member

Good thing to catch, but this isn't the right way to solve this: rather the xed25519 code should be updated to take fixed size span arguments (e.g. std::span<const unsigned char, 32>) so that it simply cannot be invoked with an invalid size in the first place.

This likely needs some fixing at some call sites to make it work properly, for instance using sp.first<32>() or similar, but then the onus falls entirely on the call site to make sure the input is valid, and not on the function itself.

@Ap4sh

Ap4sh commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Looking at this 👍

@Ap4sh
Ap4sh force-pushed the fix-xed25519-input-sizes branch from 7e823e0 to 89c6acb Compare August 6, 2026 13:26
@Ap4sh Ap4sh changed the title Validate XEd25519 input sizes Use fixed-size spans for XEd25519 inputs Aug 6, 2026
@Ap4sh

Ap4sh commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

updated this to use fixed-size spans for the binary API, with the string overloads validating before converting to them

i also updated the blinding and group-key call sites, and reran the full release test suite

thanks for pointing me in the right direction

@jagerman
jagerman enabled auto-merge August 6, 2026 19:10

@jagerman jagerman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, thanks for the PR!

@jagerman
jagerman merged commit 2b27d27 into session-foundation:dev Aug 6, 2026
1 check passed
jagerman added a commit that referenced this pull request Aug 6, 2026
Forward-port of #114 (dev commit 89c6acb) onto pfs.

Most of #114 is already here: the byte refactor (7662405) had independently
given the binary API fixed-extent spans, so sign/verify/pubkey already reject
wrong sizes at compile time, the string overloads already validate, and the
blinding / group-keys call sites already pass sized views.  Two things were
missing.

First, pfs's verify(string_view) returned false for a wrong-sized signature or
pubkey where #114 throws std::invalid_argument, so it conflated "you passed a
malformed argument" with "this signature does not verify".  Align with dev:
letting pfs keep return-false would silently revert #114's behaviour when pfs
eventually lands on dev.  Nothing in the tree calls the string overloads --
every call site uses the span overloads -- and the return-false came in
incidentally with 7662405 rather than as a considered choice.

Second, port #114's regression test for the rejected sizes.

The three string overloads all validated a length and then narrowed to a fixed
span; that is now one require_bytes<N> helper, which also gives the arguments
#114's exception wording.
jagerman added a commit that referenced this pull request Aug 6, 2026
Records dev up to 2b27d27 as merged, keeping pfs's tree unchanged (-s ours).
All four PRs in the range are now applied to pfs:

- #116 (this-is-not-c)                 via #115 this-is-not-c-pfs
- #118 (renewal-target-no-proof-fetch) via #119 renewal-target-no-proof-fetch-pfs
- #120 (macOS C response holders)      forward-ported in e682e6b
- #114 (fixed-size XEd25519 spans)     forward-ported in b03709d

Verified for the two that were already applied: #119's user_profile.cpp change
is line-identical to #118's, and for #116/#115 the `errs` error-vector is gone
from both branches with identical parse_error usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants