Draft prototype for the EXODUS verifier in solidity.
Go to file
Uncle Fatso 2b3eb14012
align comments and fix numeration of steps
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
2025-10-12 22:15:10 +03:00
lib initial commit 2025-10-07 21:12:32 +03:00
src align comments and fix numeration of steps 2025-10-12 22:15:10 +03:00
test ability to add mixed points 2025-10-12 22:10:58 +03:00
.gitignore initial commit 2025-10-07 21:12:32 +03:00
.gitmodules initial commit 2025-10-07 21:12:32 +03:00
foundry.toml initial commit; double, addition, division are already optimized 2025-10-12 16:25:36 +03:00
raw_vectors.json initial commit; double, addition, division are already optimized 2025-10-12 16:25:36 +03:00
README.md initial commit; double, addition, division are already optimized 2025-10-12 16:25:36 +03:00

EXODUS - EXchange Of Digital Uniformed Signatures

Overview

This module optimizes a hot spot in the verification formula used for missingsigner recovery. The target expression is:

k*P + l*Q + d*M

which requires three scalar multiplications and two point additions. Naive ellipticcurve routines make this very gasexpensive; this work reduces cost while maintaining correctness.

For full background and protocol details see the project wiki.

Goals

  • Reduce gas for the targeted combination of scalar multiplications and additions.
  • Keep implementation compact and auditable for onchain use.
  • Maintain correctness and safety for cryptographic operations.

Design choices

  • Use Projective coordinates (not Jacobian) to cut down on the number of mulmod/addmod operations where possible while retaining simple formulas for point addition and doubling.
  • Perform the final conversion to affine coordinates with an optimized Extended Euclidean Algorithm implemented in inline assembly to reduce gas compared with highlevel inversion routines.
  • Benchmark against the Jacobian implementation from the witnet ellipticcurvesolidity project as a reference.

Rationale

  • Projective coordinates: fewer modular multiplications in the common path, making point operations cheaper on average.
  • Assembly Extended Euclidean Algorithm for inversion: this algorithm in optimized inline assembly typically yields lower gas for single inversions compared with repeated mulmod exponentiation or other higherlevel approaches.
  • Comparing to a wellmaintained Jacobian implementation gives a meaningful baseline for gas and correctness.

Gas Usage

Jacobian is the original implementation used as a reference implementation, while Projective is optimized one.

╭----------------------------------------+-----------------+-------+--------+-------+---------╮
| src/MathTester.sol:MathTester Contract |                 |       |        |       |         |
+=============================================================================================+
| Deployment Cost                        | Deployment Size |       |        |       |         |
|----------------------------------------+-----------------+-------+--------+-------+---------|
| 1065323                                | 4715            |       |        |       |         |
|----------------------------------------+-----------------+-------+--------+-------+---------|
|                                        |                 |       |        |       |         |
|----------------------------------------+-----------------+-------+--------+-------+---------|
| Function Name                          | Min             | Avg   | Median | Max   | # Calls |
|----------------------------------------+-----------------+-------+--------+-------+---------|
| addJacobian                            | 1768            | 1768  | 1768   | 1768  | 44      |
|----------------------------------------+-----------------+-------+--------+-------+---------|
| addProjective                          | 992             | 992   | 992    | 992   | 44      |
|----------------------------------------+-----------------+-------+--------+-------+---------|
| doubleJacobian                         | 777             | 777   | 777    | 777   | 45      |
|----------------------------------------+-----------------+-------+--------+-------+---------|
| doubleProjective                       | 532             | 532   | 532    | 532   | 45      |
|----------------------------------------+-----------------+-------+--------+-------+---------|
| toAffineJacobian                       | 30564           | 36206 | 36300  | 40841 | 89      |
|----------------------------------------+-----------------+-------+--------+-------+---------|
| toAffineProjective                     | 11838           | 13792 | 13796  | 15155 | 89      |
╰----------------------------------------+-----------------+-------+--------+-------+---------╯

Contributing

All contributions are welcome — whether it's code, documentation, tests, performance benchmarks, or review. Please submit commits, issues, or pull requests; any help to improve correctness, security, or gas efficiency is greatly appreciated.