newton-core 0.4.16

newton protocol core sdk
//! Threshold decryption infrastructure for Newton Privacy Layer Phase 2.
//!
//! Implements t-of-n threshold HPKE decryption where operators hold key shares
//! produced by Feldman VSS. Each operator computes a partial DH output with a
//! DLEQ proof of correctness. The gateway combines valid partials via Lagrange
//! interpolation and feeds the result into the post-DH HPKE pipeline.
//!
//! # Modules
//!
//! - [`types`]: Core types — [`KeyShare`], [`PartialDecryption`], [`DleqProof`], etc.
//! - [`dealer`]: Trusted dealer Feldman VSS share generation (Phase 2A).
//! - [`dleq`]: DLEQ proof generation and verification.
//! - [`combine`]: Lagrange interpolation and full threshold decryption.
//!
//! # Example
//!
//! ```rust,ignore
//! use newton_core::dkg::{dealer, combine, types::ThresholdConfig};
//!
//! // Dealer generates 3-of-5 shares
//! let config = ThresholdConfig { threshold: 3, total: 5 };
//! let (tpk, commitment, shares) = dealer::generate_shares(config)?;
//!
//! // Client encrypts to tpk.hpke_public_key using standard HPKE
//! // ... (enc, ciphertext) = hpke::encrypt(tpk.hpke_public_key, plaintext, aad)
//!
//! // Each operator computes a partial decryption
//! let enc_edwards = combine::montgomery_to_edwards(&enc_bytes)?;
//! let partial = combine::compute_partial_decryption(
//!     share.index, &share.secret_share, &enc_edwards,
//! );
//!
//! // Gateway combines and decrypts
//! let plaintext = combine::threshold_decrypt(
//!     &partials, &enc, &tpk.hpke_public_key, &ciphertext, &aad,
//!     &public_shares, config.threshold,
//! )?;
//! ```

pub mod combine;
pub mod config;
pub mod dealer;
pub mod dleq;
#[cfg(feature = "frost-dkg")]
pub mod frost;
#[cfg(feature = "frost-dkg")]
pub mod keystore;
#[cfg(feature = "frost-dkg")]
pub mod refresh;
pub mod types;

pub use combine::{
    compute_partial_decryption, montgomery_to_edwards, threshold_context_from_public_shares, threshold_decrypt,
};
pub use config::{EpochConfig, ThresholdGatewayConfig, ThresholdOperatorConfig};
pub use dealer::{generate_shares, generate_shares_from_secret, verify_share};
#[cfg(feature = "frost-dkg")]
pub use refresh::{
    accumulate_refresh, combine_reshare, evaluate_at, generate_refresh_polynomial, generate_reshare_polynomial,
    polynomial_commitments, verify_refresh_share,
};
pub use types::{
    DleqProof, EpochMetadata, KeyShare, PartialDecryption, ThresholdConfig, ThresholdDecryptionContext,
    ThresholdPublicKey, VssCommitment,
};