Skip to content

Patches#95

Draft
kayabaNerve wants to merge 296 commits intoseraphis-migration:fcmp++-stagefrom
kayabaNerve:patches
Draft

Patches#95
kayabaNerve wants to merge 296 commits intoseraphis-migration:fcmp++-stagefrom
kayabaNerve:patches

Conversation

@kayabaNerve
Copy link
Copy Markdown

Builds on #93.

Uses a commit for crypto-bigint instead of a branch specification.

Forks dalek-ff-group to use a FieldElement type exposed from curve25519-dalek, as proposed in dalek-cryptography/curve25519-dalek#787. This backports those changes onto the 4.x release branch, as required by our MSRV, and adds in a FFI-compatible representation.

Additionally, the fork of curve25519-dalek explicitly and solely uses the fiat backend which has been formally verified due to a preference expressed by @j-berman. eece472 provides commentary in that regard.

Untested on 32-bit platforms. The CI should be updated to cd into the newly added dalek-ff-group folder and run cargo test --all-features on 32/64-bit platforms.

jeffro256 and others added 30 commits August 6, 2025 13:55
jeffro256 and others added 14 commits August 21, 2025 10:34
FFI: remove all unwraps and asserts, use err ints
…len-out

FFI: rm extra fcmp_proof_out_len param
See monero-project/research-lab#142 for context.

https://elligator.org/design, a third-party website commenting on/promoting
Elligator due to its adoptance by standardization organizations, includes a
section on the uniformity of Elligator. They note adding two samples is
sufficient to cover the curve, with the relevant paragraph claiming to be
feedback from an author
(LoupVaillant/elligator@feca3da).

An author also published a paper on acheiving uniformity
(https://eprint.iacr.org/2020/1513) which notes the sum of two invocations has
bias bounded to ~10/sqrt(q). This would suggest a few bits of bias are still
technically present, which further argues for this as it'll have _less_ bias
than the original (for which we've been primarily discussing the 1 bit of
_explicit_ bias).

The unbiased hash-to-curve invokes a 64-byte hashing algorithm (Blake2b-512, as
in-tree and preferable) to obtain two separate inputs for the traditional
Elligator map (`hash[.. 32]` and `hash[32 ..]`). Both are mapped, then the
results are summed. Two successive calls to `keccak256` could be done _if done
carefully_. Defining the second keccak to have an input of the result of the
first hash-to-point would be _critically flawed_. Using a 64-byte hash should
be quicker, Keccak-512 doesn't appear to be in-tree, and I prefer Blake2b-512
anyways (which is already in the protocol due to its usage within FCMP++s).

Required now for the TUV generators, which use this as their methodology. They
arguably don't need to, yet it's good practice and gets this in the codebase
now. The existing test that the TUV generators match Rust's prove this C++
function is equivalent to the Rust function.

Long-term, we should use this for at least all new key images' generators
(which require a collision-resistance property). @jeffro256 has volunteered
there.

There may be incentive to further change the hash-to-curve. This one attempts
to be as minimal as possible, keeping all of the existing hash-to-point. We
could instead follow the
[IRTF specification](https://www.rfc-editor.org/rfc/rfc9380.html). The primary
change would be how the Cryptonote developers used which candidate `u`
coordinate was chosen to determine if the resulting `y` coordinate was
even/odd. The RFC used which candidate `u` coordinate was chosen to determine
the resulting `v` coordinate was even/odd. A Curve25519 implementation of the
RFC can be used, if the choice of candidate is recovered from if `v` is
even/odd, then the result is mapped to Ed25519 and the sign is fixed?

It should also be noted this is likely inefficient, as we sample two Curve25519
points, map them to Ed25519, and sum them. Performing the addition on
Curve25519 would avoid one invocation of the map. This is just a further change
from the existing code.
@kayabaNerve kayabaNerve marked this pull request as draft August 27, 2025 22:56
@kayabaNerve
Copy link
Copy Markdown
Author

Converted to draft as I can't in good faith recommended this PR due to the multiple sets of patches it depends on.

Causes build times to minimize due to use of these dependencies at build time.
…9 from curve25519-dalek

Specifically, this uses the fiat-crypto backend for curve25519-dalek which has
been formally verified. Notably, since we're now resolving to solely a single
backend, we could alternatively not use a patch of curve25519-dalek yet add a
direct dependency of fiat-crypto to the dalek-ff-group fork to achieve (almost)
the same result. Currently, we'll only benefit from curve25519-dalek providing
some more tooling around fiat-crypto and switching between the 32- and 64-bit
variants.

This has been tested on 64-bit platforms. This has yet to be tested on 32-bit
platforms.
I originally patched to 0.2.1 by accident.
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.

4 participants