Skip to content

feat: implement Ed25519 signature validation for price updates#308

Open
dominiccreates wants to merge 4 commits into
StellarFlow-Network:mainfrom
dominiccreates:feature/ed25519-signature-validation
Open

feat: implement Ed25519 signature validation for price updates#308
dominiccreates wants to merge 4 commits into
StellarFlow-Network:mainfrom
dominiccreates:feature/ed25519-signature-validation

Conversation

@dominiccreates
Copy link
Copy Markdown

this pr closes #269
This pull request resolves the MITM vulnerability where off-chain endpoints could submit unsigned data payloads to the oracle. It enforces that all ingested payloads must be cryptographically signed by pre-approved validator keys before updates are saved.

Technical Implementation
Storage Scheme Extensions (types.rs):

Added a Validator(BytesN<32>) variant to DataKey to hold authorized validator keys.
Introduced PricePayload struct to represent the details being signed by validators off-chain:
rust

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PricePayload {
pub asset: Symbol,
pub price: i128,
pub decimals: u32,
pub confidence_score: u32,
pub ttl: u64,
}
Core Verification Logic (lib.rs):

Added administration methods: add_validator, remove_validator, and is_validator.
Updated update_price parameter signature to require signature: BytesN<64> and public_key: BytesN<32>.
Verified that public_key is registered via is_validator (rejecting unauthorized updates with Error::Unauthorized).
Reconstructed PricePayload from parameters and verified its off-chain cryptographic signature using env.crypto().ed25519_verify().
Test Suite Adaptation (test.rs):

Added ed25519-dalek to test dependencies to dynamically generate real keypairs and valid Ed25519 signatures inside tests.
Wrote wrappers do_update_price and do_try_update_price to automatically handle serialization and signing in tests.
Updated all 45+ existing test assertions to seamlessly supply valid signature arguments.
Added a dedicated unit test test_ed25519_signature_validation to verify:
Unregistered validator signatures are rejected with Error::Unauthorized.
Authentic signatures from pre-approved validator keys are processed successfully.
Keys successfully removed by the admin are rejected.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@dominiccreates Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

🛡️ Contracts | Ed25519 Off-Chain Data Signature Validation

1 participant