use pyo3::prelude::*;
use secp256k1::Message;

mod private_key;
pub mod public_key;

pub fn message_from_digest(digest: &[u8]) -> PyResult<Message> {
    if digest.len() != 32 {
        return Err(pyo3::exceptions::PyValueError::new_err(
            "message must be 32 bytes",
        ));
    }
    let mut buf = [0u8; 32];
    buf.copy_from_slice(digest);
    Ok(Message::from_digest(buf))
}

#[pymodule]
mod spec256k1 {
    #[pymodule_export]
    use super::private_key::PrivateKey;

    #[pymodule_export]
    use super::public_key::PublicKey;
}
