use qssm_le::{Commitment, LatticeProof, VerifyingKey};
use qssm_ms::GhostMirrorProof;
use zeroize::{Zeroize, ZeroizeOnDrop};
#[derive(Zeroize, ZeroizeOnDrop)]
pub struct ProofContext {
#[zeroize(skip)]
pub(crate) vk: VerifyingKey,
seed: [u8; 32],
}
impl std::fmt::Debug for ProofContext {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ProofContext")
.field("vk", &self.vk)
.field("seed", &"[REDACTED]")
.finish()
}
}
impl ProofContext {
#[must_use]
pub fn new(seed: [u8; 32]) -> Self {
Self {
vk: VerifyingKey::from_seed(seed),
seed,
}
}
#[must_use]
pub fn seed(&self) -> [u8; 32] {
self.seed
}
#[must_use]
pub fn vk(&self) -> &VerifyingKey {
&self.vk
}
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct Proof {
pub(crate) ms_root: [u8; 32],
pub(crate) ms_proof: GhostMirrorProof,
pub(crate) le_commitment: Commitment,
pub(crate) le_proof: LatticeProof,
pub(crate) external_entropy: [u8; 32],
pub(crate) external_entropy_included: bool,
pub(crate) value: u64,
pub(crate) target: u64,
pub(crate) binding_entropy: [u8; 32],
}
impl Proof {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(
ms_root: [u8; 32],
ms_proof: GhostMirrorProof,
le_commitment: Commitment,
le_proof: LatticeProof,
external_entropy: [u8; 32],
external_entropy_included: bool,
value: u64,
target: u64,
binding_entropy: [u8; 32],
) -> Self {
Self {
ms_root,
ms_proof,
le_commitment,
le_proof,
external_entropy,
external_entropy_included,
value,
target,
binding_entropy,
}
}
#[must_use]
pub fn ms_root(&self) -> &[u8; 32] {
&self.ms_root
}
#[must_use]
pub fn ms_proof(&self) -> &GhostMirrorProof {
&self.ms_proof
}
#[must_use]
pub fn le_commitment(&self) -> &Commitment {
&self.le_commitment
}
#[must_use]
pub fn le_proof(&self) -> &LatticeProof {
&self.le_proof
}
#[must_use]
pub fn external_entropy(&self) -> &[u8; 32] {
&self.external_entropy
}
#[must_use]
pub fn external_entropy_included(&self) -> bool {
self.external_entropy_included
}
#[must_use]
pub fn value(&self) -> u64 {
self.value
}
#[must_use]
pub fn target(&self) -> u64 {
self.target
}
#[must_use]
pub fn binding_entropy(&self) -> &[u8; 32] {
&self.binding_entropy
}
}