Skip to main content

alea_verifier/
lib.rs

1#![allow(unexpected_cfgs)]
2
3use anchor_lang::prelude::*;
4
5declare_id!("ALEAydzHd4cN2EWcdHKp4hehAE4B88b16gqVtVqsck2U");
6
7pub mod crypto;
8pub mod errors;
9pub mod events;
10pub mod instructions;
11pub mod state;
12
13pub use instructions::initialize::*;
14pub use instructions::update_config::*;
15pub use instructions::verify::*;
16
17// T1.04 — map_to_point_debug always re-exported (see instructions/mod.rs
18// SECURITY POSTURE for why this is always-on and safe).
19pub use instructions::map_to_point_debug::*;
20
21#[program]
22pub mod alea_verifier {
23    use super::*;
24
25    pub fn initialize(
26        ctx: Context<Initialize>,
27        pubkey_g2: [u8; 128],
28        genesis_time: u64,
29        period: u64,
30        chain_hash: [u8; 32],
31    ) -> Result<()> {
32        initialize_handler(ctx, pubkey_g2, genesis_time, period, chain_hash)
33    }
34
35    pub fn verify(ctx: Context<Verify>, round: u64, signature: [u8; 64]) -> Result<[u8; 32]> {
36        verify_handler(ctx, round, signature)
37    }
38
39    pub fn update_config(
40        ctx: Context<UpdateConfig>,
41        pubkey_g2: [u8; 128],
42        genesis_time: u64,
43        period: u64,
44        chain_hash: [u8; 32],
45    ) -> Result<()> {
46        update_config_handler(ctx, pubkey_g2, genesis_time, period, chain_hash)
47    }
48
49    // T1.04 — BPF-vs-native map_to_point parity debug instruction.
50    // Always present in the shipped binary; stateless pure function with
51    // zero attack surface. See `instructions/mod.rs` SECURITY POSTURE.
52    pub fn map_to_point_debug(
53        ctx: Context<MapToPointDebug>,
54        u_bytes: [u8; 32],
55    ) -> Result<[u8; 64]> {
56        map_to_point_debug_handler(ctx, u_bytes)
57    }
58}