Skip to content

Feat/ed25519-verify - #7196

Merged
rob-stacks merged 17 commits into
stacks-network:pox-wf-integrationfrom
rob-stacks:feat/ed25519-verify
May 29, 2026
Merged

Feat/ed25519-verify#7196
rob-stacks merged 17 commits into
stacks-network:pox-wf-integrationfrom
rob-stacks:feat/ed25519-verify

Conversation

@rob-stacks

@rob-stacks rob-stacks commented May 11, 2026

Copy link
Copy Markdown
Contributor

Description

This patch adds the ed25519-verify clarity function as well as an infrastructure for ed25519 curves.

(ed25519-verify 0x68656c6c6f20776f726c64 0x7e8346b0d9ef1151608df9d436c646b9df23758b292e0df400032f2603417724a25997d81a95a8997a55252813589b9409893df1ec75249a5b6f38753232810e 0xec172b93ad5e563bf49683c1397357b1af93d4e937abda610c10ccc6112217c0)

It expects "(buff 1024), (buff 64), (buff 32)" and returns bool (if the signature is verified)

The message buffer can be between 0 and 1024 bytes.

The signature is 64 bytes.

The public key is 32 bytes.

Cost has been profiled to 7880 units and veries very little based on the size of the message (can be between 0 and 1024) so probably it could be kept as fixed and not linear as soon as the clarity6 costs table is pushed.

Applicable issues

  • fixes #

Additional info (benefits, drawbacks, caveats)

Checklist

  • Test coverage for new or modified code paths
  • For new Clarity features or consensus changes, add property tests (see docs/property-testing.md)
  • Changelog fragment(s) or "no changelog" label added (see changelog.d/README.md)
  • Required documentation changes (e.g., rpc/openapi.yaml for RPC endpoints, event-dispatcher.md for new events)
  • New clarity functions have corresponding PR in clarity-benchmarking repo

@rob-stacks
rob-stacks marked this pull request as ready for review May 11, 2026 13:45
@coveralls

coveralls commented May 11, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 26640098042

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.03%) to 85.993%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 37 uncovered changes across 4 files (207 of 244 lines covered, 84.84%).
  • 6369 coverage regressions across 96 files.

Uncovered Changes

File Changed Covered %
stacks-common/src/util/ed25519.rs 156 134 85.9%
clarity/src/vm/functions/crypto.rs 31 20 64.52%
clarity/src/vm/costs/costs_5.rs 3 0 0.0%
clarity/src/vm/functions/mod.rs 20 19 95.0%
Total (14 files) 244 207 84.84%

Coverage Regressions

6369 previously-covered lines in 96 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
stackslib/src/chainstate/burn/db/sortdb.rs 630 90.21%
stackslib/src/config/mod.rs 418 69.43%
stackslib/src/net/mod.rs 311 77.9%
stackslib/src/chainstate/stacks/index/storage.rs 277 82.27%
clarity/src/vm/database/clarity_db.rs 259 82.14%
stackslib/src/chainstate/stacks/boot/mod.rs 248 94.21%
clarity/src/vm/database/structures.rs 236 78.07%
stackslib/src/chainstate/stacks/miner.rs 218 83.4%
stackslib/src/burnchains/burnchain.rs 216 71.23%
stackslib/src/chainstate/nakamoto/signer_set.rs 199 69.19%

Coverage Stats

Coverage Status
Relevant Lines: 225937
Covered Lines: 194290
Line Coverage: 85.99%
Coverage Strength: 18584414.86 hits per line

💛 - Coveralls

Comment thread clarity/src/vm/docs/mod.rs Outdated
Comment thread clarity/src/vm/docs/mod.rs Outdated
Comment thread stacks-common/src/util/ed25519.rs Outdated
Comment thread clarity/src/vm/analysis/type_checker/v2_1/natives/mod.rs
Comment thread clarity/src/vm/functions/crypto.rs Outdated
Comment thread clarity/src/vm/functions/crypto.rs Outdated
Comment thread stacks-common/src/util/ed25519.rs Outdated
Comment thread clarity/src/vm/tests/crypto.rs
Comment thread clarity/src/vm/functions/mod.rs Outdated
@CLAassistant

CLAassistant commented May 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@jbencin-stacks

Copy link
Copy Markdown
Contributor

I was updating the Clarity 6 SIP draft (stacksgov/sips#267) with this function, and noticed that example you use in the PR description and docs is invalid:

(ed25519-verify
  0x68656c6c6f20776f726c64 
  0x7e8346b0d9ef1151608df9d436c646b9df23758b292e0df400032f2603417724a25997d81a95a8997a55252813589b9409893df1ec75249a5b6f38753232810e
  0xec172b93ad5e563bf49683c1397357b1af93d4e937abda610c10ccc6112217c0
)

You can see for yourself here: https://cyphr.me/ed25519_tool/ed.html

We should make sure this example fails in the unit tests, and we should use the official test vectors from RFC 8032 (link) in our docs instead, and make sure we have them as part of our unit tests

@rob-stacks

Copy link
Copy Markdown
Contributor Author

@jbencin-stacks examples updated and added a test for all of the rfc-provided vectors (i added more tests for non-conforming cases too)

Comment thread stackslib/src/clarity_vm/tests/costs.rs Outdated
@rob-stacks

Copy link
Copy Markdown
Contributor Author

@brice-stacks refactored to use NativeFunction205. Note that i moved the buff_to_array32 to mod.rs and make it generic (buff_to_array::<32>, buff_to_array::<64>, ... ) as it can be useful for other functions too (i used it in ed25519-verify). With the same logic i have added buff_to_vec

@rob-stacks
rob-stacks requested a review from brice-stacks May 27, 2026 13:31
Comment thread clarity/src/vm/functions/mod.rs
@rob-stacks
rob-stacks merged commit 9debe2f into stacks-network:pox-wf-integration May 29, 2026
6 checks passed
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Closed PR has been locked after 14 days of inactivity.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants