ecdh-omr 0.2.0

ECDH based Oblivious Message Retrieval
Documentation
// SPDX-FileCopyrightText: 2024 eaon <eaon@posteo.net>
// SPDX-License-Identifier: EUPL-1.2

#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![allow(clippy::needless_doctest_main)]
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]

use aead::{Aead, KeyInit};
use rand_core::CryptoRngCore;

pub mod curves;

mod blinding;
pub use blinding::*;

mod hint;
pub use hint::*;

mod hints;
pub use hints::*;

mod take_the;
pub use take_the::*;

mod error;
pub use error::*;

/// Generate legitimate looking instances of data structures without user input.
pub trait Decoy {
    /// Create a decoy instance from provided RNG.
    fn random_decoy(csprng: &mut impl CryptoRngCore) -> Self;
}

// Turn a shared secret supplied in the form of bytes into a key usable by `aead` implementations
pub(crate) fn cipher_from_shared_secret<A: Aead + KeyInit>(shared_secret: impl AsRef<[u8]>) -> A {
    let mut key = aead::Key::<A>::default();
    key.copy_from_slice(&shared_secret.as_ref()[..A::key_size()]);

    A::new(&key)
}