Cotton code
64 lines · 1.9 KB · RustRaw
//! The fixed inputs every seal test and vector shares. Synthetic only.use serde_json::{json, Map, Value};use super::keys::DataKey;use super::row::Dek;use crate::definitions::SealSpec;use crate::keys::person::PersonKey;use crate::vault::seal::Vmk;use zeroize::Zeroizing;pub const DATABASE: &str = "11111111-1111-4111-8111-111111111111";pub const OTHER_DATABASE: &str = "22222222-2222-4222-8222-222222222222";pub const ROW_ID: &str = "5b1c0e7a-0000-4000-8000-000000000001";pub fn dk_bytes() -> [u8; 32] {    std::array::from_fn(|i| i as u8)}pub fn dk() -> DataKey {    DataKey::from_bytes(dk_bytes())}pub fn vmk() -> Vmk {    Vmk::from_bytes([0x42; 32])}pub fn dek() -> Dek {    Dek::from_bytes([0x24; 32])}pub fn nonce(byte: u8) -> [u8; 12] {    [byte; 12]}pub fn person() -> PersonKey {    PersonKey::from_seed(Zeroizing::new([7; 32]))}pub const WORKER_SECRET: [u8; 32] = [9; 32];pub const EPHEMERAL: [u8; 32] = [5; 32];pub const SHARE_SECRET: [u8; 32] = [11; 32];pub fn message_spec() -> SealSpec {    SealSpec {        clear: ["sent_at", "thread_id", "reply_to_id", "channel", "trashed_at"].map(String::from).to_vec(),        blind: ["body", "preview"].map(String::from).to_vec(),        blind_exact: vec!["external_id".into()],        blind_bytes: Default::default(),    }}pub fn message_row() -> Map<String, Value> {    match json!({        "id": ROW_ID,        "sent_at": "2026-11-11T09:14:03Z",        "thread_id": "5b1c0e7a-0000-4000-8000-0000000000aa",        "reply_to_id": null,        "channel": "whatsapp",        "trashed_at": null,        "body": "Zanzibar ferry tickets for Thursday, café near the jetty",        "preview": "Zanzibar ferry tickets",        "external_id": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAEhgg",        "sender_handle": "+919876543210",        "reactions": ["👍"]    }) {        Value::Object(map) => map,        _ => unreachable!(),    }}