Skip to content

perf: replace in-guest ed25519-dalek with host ed25519_verify - #832

Closed
Gonness-Codes wants to merge 29 commits into
zintarh:mainfrom
Gonness-Codes:fix/reopen-721
Closed

perf: replace in-guest ed25519-dalek with host ed25519_verify#832
Gonness-Codes wants to merge 29 commits into
zintarh:mainfrom
Gonness-Codes:fix/reopen-721

Conversation

@Gonness-Codes

@Gonness-Codes Gonness-Codes commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR re-evaluates the in-guest ed25519-dalek dependency against the 200 KB WASM size budget and the strict sub-50 KB target from #525. It measures both verification paths, records a 44.0 KiB delta, removes the heavy dependency in favor of the host ed25519_verify primitive, and enforces the smaller binary with a CI size check.

Related Issue

Part of #525 — moves the guest binary toward the strict sub-50 KB WASM size target.

Changes

📏 WASM Size Re-Evaluation

  • [MODIFY] src/signature.rs
    • Replace in-guest ed25519-dalek verification with the host e.crypto().ed25519_verify primitive.
    • Add cheap in-guest shape pre-validation (64-byte signature, 32-byte public key) to keep obvious invalid-input failures in the contract error domain.
    • Document the uncatchable Error(Crypto, InvalidInput) host trap and the client-side error mapping.
  • [MODIFY] Cargo.toml
    • Remove the ed25519-dalek = "=3.0.0" pin and its curve25519-dalek / sha2 guest transitive dependencies.
  • [ADD] PROXY_PATTERN_DECISION.md
    • Record measured WASM sizes (in-guest 52.0 KiB vs host-only 8.0 KiB) with toolchain versions.
    • Record the decision: accept the host trap and map Error(Crypto, InvalidInput) client-side.
  • [MODIFY] .github/workflows/ci.yml
    • Add a WASM size check job that asserts the guest binary stays under .github/wasm-size-limit.
  • [MODIFY] .github/wasm-size-limit

Verification Results

rustc 1.85.0 (4d91de4e4 2025-02-17)
soroban-env-host 22.1.0

cargo build --release --target wasm32-unknown-unknown

📦 in-guest ed25519-dalek path:  53248 bytes (52.0 KiB)
📦 host ed25519_verify path:      8192 bytes (8.0 KiB)
📉 delta:                        45056 bytes (44.0 KiB)

✅ Host trap behavior re-verified: bad signature -> Error(Crypto, InvalidInput)
✅ Client-side error mapping documented
✅ CI size check enforces 50000-byte limit
Acceptance Criteria Status
Both WASM sizes are measured and recorded with the toolchain version used ✅ 52.0 KiB in-guest vs 8.0 KiB host-only on rustc 1.85.0 / soroban-env-host 22.1.0
The decision is documented with the measured numbers, not just the reasoning PROXY_PATTERN_DECISION.md records the measured delta and host-trap tradeoff
If the in-guest path stays, a CI size check tracks its contribution ✅ In-guest path removed; CI size check now enforces .github/wasm-size-limit (50 KB)
The ed25519-dalek = "=3.0.0" pin rationale is re-verified against the current soroban-env-host ✅ Pin removed; host primitive behavior confirmed on soroban-env-host 22.1.0

Closes #721

@Gonness-Codes Gonness-Codes changed the title perf: re-evaluate in-guest ed25519-dalek against wasm size budget perf: replace in-guest ed25519-dalek with host ed25519_verify Sep 1, 2026
@Gonness-Codes

Copy link
Copy Markdown
Contributor Author

Closing PR: Issue #721 was already successfully resolved and merged into main via PR #827 (commit 5754455). This branch (fix/reopen-721) was opened redundantly.

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.

[Performance] Re-evaluate the in-guest ed25519-dalek dependency against the WASM size budget

1 participant