use clap::{Args, Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(
name = "confium",
version,
about = "Confium trust store framework",
long_about = "Confium trust store framework — install and manage cryptographic plugins.",
propagate_version = true
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Install(InstallArgs),
Remove(RemoveArgs),
Update(UpdateArgs),
List(ListArgs),
Info(InfoArgs),
Search(SearchArgs),
Trust(TrustArgs),
Config(ConfigArgs),
Version,
Completions(CompletionsArgs),
#[command(name = "threshold", subcommand)]
Threshold(ThresholdCommand),
#[command(name = "transparency", subcommand)]
Transparency(TransparencyCommand),
#[command(name = "pki", subcommand)]
Pki(PkiCommand),
#[command(name = "keyless", subcommand)]
Keyless(KeylessCommand),
#[command(name = "privacy", subcommand)]
Privacy(PrivacyCommand),
#[command(name = "verify", subcommand)]
Verify(VerifyCommand),
}
#[derive(Subcommand, Debug)]
pub enum ThresholdCommand {
Version,
Dkg(ThresholdDkgArgs),
Sign(ThresholdSignArgs),
Refresh(ThresholdRefreshArgs),
Recover,
MigrateShares(ThresholdMigrateSharesArgs),
}
#[derive(Args, Debug)]
pub struct ThresholdRefreshArgs {
#[arg(long)]
pub shares: std::path::PathBuf,
#[arg(long)]
pub out: std::path::PathBuf,
}
#[derive(Args, Debug)]
pub struct ThresholdMigrateSharesArgs {
#[arg(long)]
pub input: std::path::PathBuf,
#[arg(long)]
pub out: std::path::PathBuf,
#[arg(long, default_value = "CMP20-ECDSA-P256")]
pub scheme: String,
#[arg(long, default_value_t = 2)]
pub threshold: u32,
#[arg(long, default_value_t = 3)]
pub parties: u32,
}
#[derive(Args, Debug)]
pub struct CompletionsArgs {
#[arg(value_parser = ["bash", "zsh", "fish", "elvish", "powershell"])]
pub shell: String,
}
#[derive(Args, Debug)]
pub struct ThresholdDkgArgs {
#[arg(long, default_value = "cmp20")]
pub scheme: String,
#[arg(long)]
pub threshold: u32,
#[arg(long)]
pub parties: u32,
#[arg(long)]
pub out: Option<std::path::PathBuf>,
}
#[derive(Args, Debug)]
pub struct ThresholdSignArgs {
#[arg(long)]
pub shares: std::path::PathBuf,
#[arg(long)]
pub message: String,
#[arg(long)]
pub out: Option<std::path::PathBuf>,
}
#[derive(Subcommand, Debug)]
pub enum TransparencyCommand {
Version,
Append(TransparencyAppendArgs),
Prove(TransparencyProveArgs),
Verify(TransparencyVerifyArgs),
}
#[derive(Args, Debug)]
pub struct TransparencyAppendArgs {
#[arg(long, default_value = "./transparency.db")]
pub db: std::path::PathBuf,
#[arg(long)]
pub artifact_hash: String,
}
#[derive(Args, Debug)]
pub struct TransparencyProveArgs {
#[arg(long, default_value = "./transparency.db")]
pub db: std::path::PathBuf,
#[arg(long)]
pub seq: usize,
#[arg(long)]
pub out: Option<std::path::PathBuf>,
}
#[derive(Args, Debug)]
pub struct TransparencyVerifyArgs {
#[arg(long)]
pub proof: std::path::PathBuf,
#[arg(long)]
pub head: std::path::PathBuf,
}
#[derive(Subcommand, Debug)]
pub enum PkiCommand {
Version,
ParseCert(PkiParseCertArgs),
Verify(PkiVerifyArgs),
CompositeSign(PkiCompositeSignArgs),
}
#[derive(Args, Debug)]
pub struct PkiParseCertArgs {
#[arg(long)]
pub cert: std::path::PathBuf,
#[arg(long, default_value = "der")]
pub format: String,
}
#[derive(Args, Debug)]
pub struct PkiVerifyArgs {
#[arg(long)]
pub leaf: std::path::PathBuf,
#[arg(long)]
pub anchor: std::path::PathBuf,
#[arg(long = "intermediate")]
pub intermediates: Vec<std::path::PathBuf>,
#[arg(long, default_value = "der")]
pub format: String,
}
#[derive(Args, Debug)]
pub struct PkiCompositeSignArgs {
#[arg(long)]
pub message: String,
#[arg(long)]
pub ed25519_key: std::path::PathBuf,
#[arg(long)]
pub p256_key: std::path::PathBuf,
#[arg(long)]
pub out: Option<std::path::PathBuf>,
}
#[derive(Subcommand, Debug)]
pub enum KeylessCommand {
Version,
Sign,
Verify,
}
#[derive(Subcommand, Debug)]
pub enum PrivacyCommand {
Version,
Psi(PrivacyPsiArgs),
Dp(PrivacyDpArgs),
Mpc,
}
#[derive(Args, Debug)]
pub struct PrivacyPsiArgs {
#[arg(long)]
pub set_a: std::path::PathBuf,
#[arg(long)]
pub set_b: std::path::PathBuf,
#[arg(long, default_value = "/dev/urandom")]
pub salt: std::path::PathBuf,
#[arg(long)]
pub cardinality_only: bool,
}
#[derive(Args, Debug)]
pub struct PrivacyDpArgs {
#[arg(long)]
pub value: f64,
#[arg(long)]
pub sensitivity: f64,
#[arg(long)]
pub epsilon: f64,
#[arg(long, default_value = "laplace")]
pub distribution: String,
#[arg(long, default_value = "0.00001")]
pub delta: f64,
}
#[derive(Subcommand, Debug)]
pub enum VerifyCommand {
Version,
Composite(VerifyCompositeArgs),
Inclusion(VerifyInclusionArgs),
CertChain(VerifyCertChainArgs),
Signatif(VerifySignatifArgs),
}
#[derive(Args, Debug)]
pub struct VerifyCompositeArgs {
#[arg(long)]
pub message: String,
#[arg(long)]
pub signature: std::path::PathBuf,
#[arg(long)]
pub algorithm: String,
#[arg(long)]
pub public_key: std::path::PathBuf,
}
#[derive(Args, Debug)]
pub struct VerifyInclusionArgs {
#[arg(long)]
pub proof: std::path::PathBuf,
#[arg(long)]
pub entry: std::path::PathBuf,
}
#[derive(Args, Debug)]
pub struct VerifySignatifArgs {
#[arg(long)]
pub artifact: std::path::PathBuf,
#[arg(long)]
pub bundle: std::path::PathBuf,
#[arg(long)]
pub graph: std::path::PathBuf,
#[arg(long)]
pub registry: Option<std::path::PathBuf>,
#[arg(long, value_delimiter = ',')]
pub accept: Vec<String>,
#[arg(long, default_value_t = false)]
pub transparency: bool,
#[arg(long, default_value_t = false)]
pub time: bool,
#[arg(long)]
pub time_attested_at: Option<String>,
}
#[derive(Args, Debug)]
pub struct VerifyCertChainArgs {
#[arg(long)]
pub leaf: std::path::PathBuf,
#[arg(long)]
pub anchor: std::path::PathBuf,
#[arg(long = "intermediate")]
pub intermediates: Vec<std::path::PathBuf>,
#[arg(long, default_value = "der")]
pub format: String,
}
#[derive(Args, Debug)]
pub struct InstallArgs {
pub plugin: String,
}
#[derive(Args, Debug)]
pub struct RemoveArgs {
pub plugin: String,
}
#[derive(Args, Debug)]
pub struct UpdateArgs {
pub plugin: Option<String>,
}
#[derive(Args, Debug)]
pub struct ListArgs {}
#[derive(Args, Debug)]
pub struct InfoArgs {
pub plugin: String,
}
#[derive(Args, Debug)]
pub struct SearchArgs {
pub interface: Option<String>,
pub algorithm: Option<String>,
}
#[derive(Args, Debug)]
pub struct TrustArgs {
#[command(subcommand)]
pub action: TrustAction,
}
#[derive(Subcommand, Debug)]
pub enum TrustAction {
List,
Add(TrustAddArgs),
Remove(TrustRemoveArgs),
}
#[derive(Args, Debug)]
pub struct TrustAddArgs {
pub publisher: String,
#[arg(long)]
pub key: Option<String>,
}
#[derive(Args, Debug)]
pub struct TrustRemoveArgs {
pub publisher: String,
}
#[derive(Args, Debug)]
pub struct ConfigArgs {
#[command(subcommand)]
pub action: ConfigAction,
}
#[derive(Subcommand, Debug)]
pub enum ConfigAction {
Edit,
Show,
Set(ConfigSetArgs),
Get(ConfigGetArgs),
}
#[derive(Args, Debug)]
pub struct ConfigSetArgs {
pub key: String,
pub value: String,
}
#[derive(Args, Debug)]
pub struct ConfigGetArgs {
pub key: String,
}