#![cfg_attr(docsrs, feature(doc_cfg))]
#![no_std]
#![allow(non_snake_case)]
#![cfg_attr(feature = "secp256k1", doc = include_str!("../README.md"))]
#![deny(missing_docs, warnings)]
use core::fmt::Debug;
use digest::Update;
pub use generic_array::{self, typenum};
use generic_array::{ArrayLength, GenericArray};
pub use rand_core;
use rand_core::{CryptoRng, RngCore};
#[cfg(test)]
#[macro_use]
extern crate std;
#[cfg(feature = "alloc")]
#[allow(unused_imports)]
#[macro_use]
extern crate alloc;
#[cfg(feature = "secp256k1")]
#[cfg_attr(docsrs, doc(cfg(feature = "secp256k1")))]
pub mod secp256k1;
#[cfg(feature = "ed25519")]
#[cfg_attr(docsrs, doc(cfg(feature = "ed25519")))]
pub mod ed25519;
mod and;
pub use and::And;
mod eq;
pub use eq::Eq;
#[cfg(feature = "alloc")]
mod eq_all;
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub use eq_all::EqAll;
mod or;
pub use or::*;
#[cfg(feature = "alloc")]
mod all;
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
pub use all::All;
pub mod ext;
mod transcript;
pub use transcript::*;
mod fiat_shamir;
pub use fiat_shamir::*;
mod writable;
pub use writable::*;
pub trait Sigma: Writable {
type Witness: Debug;
type Statement: Debug;
type AnnounceSecret: Debug;
type Announcement: core::cmp::Eq + Debug;
type Response: Debug;
type ChallengeLength: ArrayLength<u8>;
fn announce(
&self,
statement: &Self::Statement,
announce_secret: &Self::AnnounceSecret,
) -> Self::Announcement;
fn gen_announce_secret<Rng: CryptoRng + RngCore>(
&self,
witness: &Self::Witness,
rng: &mut Rng,
) -> Self::AnnounceSecret;
fn sample_response<Rng: CryptoRng + RngCore>(&self, rng: &mut Rng) -> Self::Response;
fn respond(
&self,
witness: &Self::Witness,
statement: &Self::Statement,
announce_secret: Self::AnnounceSecret,
announce: &Self::Announcement,
challenge: &GenericArray<u8, Self::ChallengeLength>,
) -> Self::Response;
fn implied_announcement(
&self,
statement: &Self::Statement,
challenge: &GenericArray<u8, Self::ChallengeLength>,
response: &Self::Response,
) -> Option<Self::Announcement>;
fn hash_statement<H: Update>(&self, hash: &mut H, statement: &Self::Statement);
fn hash_announcement<H: Update>(&self, hash: &mut H, announcement: &Self::Announcement);
fn hash_witness<H: Update>(&self, hash: &mut H, witness: &Self::Witness);
}
#[macro_export]
#[doc(hidden)]
macro_rules! impl_display {
($name:ident<$($tp:ident),+>) => {
impl<$($tp),+> core::fmt::Display for $name<$($tp),+>
where $name<$($tp),+>: $crate::Sigma
{
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
use $crate::Writable;
self.write_to(f)
}
}
}
}