Skip to main content

molpha_verifier/
payload.rs

1//! Plain `DataUpdate` payload struct.
2//!
3//! Field order and types match the on-chain `SubmitDataUpdateArgs` instruction argument so a
4//! mechanical field copy converts between the two. With the `borsh` feature enabled the byte
5//! layout also matches the 129-byte anchor borsh layout, but the crate does not rely on that.
6//!
7//! The signed message commits to the feed value as `keccak256(raw_value)` plus its byte length
8//! rather than carrying those fields in the wire payload. The raw bytes travel alongside and are
9//! hashed into the message during verification ([`crate::message::compute_message_hash`]).
10
11/// A signed Molpha data update.
12///
13/// Borsh layout (129 bytes): `feed_id` (32) + `registry_version` (4) + `canonical_timestamp` (8) +
14/// `signatures_required` (1) + `agg_sig_s` (32) + `commitment_addr` (20) + `signers_bitmap` (32).
15#[derive(Clone, Debug, PartialEq, Eq)]
16#[cfg_attr(
17    feature = "borsh",
18    derive(borsh::BorshSerialize, borsh::BorshDeserialize)
19)]
20pub struct DataUpdate {
21    pub feed_id: [u8; 32],
22    pub registry_version: u32,
23    pub canonical_timestamp: i64,
24    pub signatures_required: u8,
25
26    /// Aggregate Schnorr signature scalar `s`.
27    pub agg_sig_s: [u8; 32],
28    /// Ethereum-style commitment address (20 bytes).
29    pub commitment_addr: [u8; 20],
30    /// EVM `uint256` bitmap (big-endian) of which nodes signed.
31    pub signers_bitmap: [u8; 32],
32}