Skip to main content

molpha_verifier/
lib.rs

1//! Molpha DataUpdate aggregate-Schnorr verification.
2//!
3//! A framework-agnostic library (no Anchor / Pinocchio dependency): the downstream program owns the
4//! registry account types and reads them, then passes plain data in. Verify a Molpha [`DataUpdate`]
5//! either from already-resolved signer pubkeys ([`verify_data_update`]) or from parsed registry
6//! entries plus a [`RegistryView`] ([`verify_data_update_resolved`]).
7//!
8//! # Usage
9//! ```ignore
10//! use molpha_verifier::{verify_data_update, DataUpdate};
11//!
12//! // `raw_value` is the raw feed value carried alongside the payload; it is hashed into the
13//! // signed message (`keccak256` + length). `ordered_signers` are the signing nodes' (x, y)
14//! // pubkeys in ascending signers_bitmap bit order.
15//! verify_data_update(&payload, raw_value, node_count, redundancy_buffer, &ordered_signers)?;
16//! ```
17
18pub mod bitmap;
19pub mod coalition;
20pub mod error;
21pub mod message;
22pub mod onchain;
23pub mod payload;
24pub mod scalar;
25pub mod selection;
26pub mod state;
27#[cfg(test)]
28mod test_signer;
29pub mod verify;
30
31pub use error::DataUpdateError;
32pub use onchain::*;
33pub use payload::DataUpdate;
34pub use state::*;
35
36// High-level verification API.
37pub use verify::{
38    reconstruct_coalition_key, reconstruct_coalition_key_compressed, verify_aggregate_over_hash,
39    verify_data_update, verify_data_update_compressed, SignerXy,
40};
41
42// Primitives commonly composed by on-chain callers.
43pub use bitmap::{
44    bitmap_is_subset_u256, bitmap_load, derive_group_bitmap, effective_selection_size,
45    for_each_set_bit_u256,
46};
47pub use coalition::CoalitionAccumulator;
48pub use message::{compute_message_hash, value_commitment, MESSAGE_PREFIX};
49pub use scalar::{
50    eth_address_from_uncompressed_pubkey, evm_schnorr_ecdsa_inputs,
51    secp256k1_scalar_is_valid_nonzero,
52};
53pub use selection::{derive_selection_bitmap, SELECTION_SEED_PREFIX};