From 35977664fcd4d433328d174809652e4e413e2652 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Raynaud Date: Sat, 13 Apr 2024 12:18:48 +0200 Subject: [PATCH] fix: rename statement to public input --- README.md | 16 ++++++++-------- src/circuit.rs | 20 +++++++------------- src/commands/mod.rs | 4 ++-- src/commands/prove.rs | 8 ++++---- src/commands/verify.rs | 8 ++++---- src/lib.rs | 2 +- src/model.rs | 12 ++++++------ 7 files changed, 32 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 6cdd527..456d058 100644 --- a/README.md +++ b/README.md @@ -105,13 +105,13 @@ Here are the available commands: $ ./digitsum prove --help Run the prover for the digit sum circuit -Usage: digitsum prove [OPTIONS] --witness --statement +Usage: digitsum prove [OPTIONS] --witness --public-input Options: -w, --witness Secret number that Alice knows (a.k.a. the witness) - -s, --statement - Public number that Bob knows and which represents the sum of the digits of the witness (a.k.a. the statement) + -p, --public-input + Public number that Bob knows and which represents the sum of the digits of the witness (a.k.a. the public input) --proof-file-name Proof export filename [default: proof.hex] --proof-export-dir @@ -126,11 +126,11 @@ Options: $ ./digitsum verify --help Run the verifier for the digit sum circuit -Usage: digitsum verify [OPTIONS] --statement +Usage: digitsum verify [OPTIONS] --public-input Options: - -s, --statement - Public number that Bob knows and which represents the sum of the digits of the witness (a.k.a. the statement) + -p, --public-input + Public number that Bob knows and which represents the sum of the digits of the witness (a.k.a. the public input) --proof-file-name Proof import filename [default: proof.hex] --proof-import-dir @@ -169,7 +169,7 @@ Options: Create a proof with the `prove` sub-command: ```bash -$ ./digitsum prove --witness 123 --statement 6 --proof-file-name proof.hex +$ ./digitsum prove --witness 123 --public-input 6 --proof-file-name proof.hex >> Proof generated to "./proof.hex" ``` @@ -178,7 +178,7 @@ $ ./digitsum prove --witness 123 --statement 6 --proof-file-name proof.hex Verify a proof with the `verify` sub-command: ```bash -$ ./digitsum verify --statement 6 --proof-file-name proof.hex +$ ./digitsum verify --public-input 6 --proof-file-name proof.hex >> Proof verified! ``` diff --git a/src/circuit.rs b/src/circuit.rs index acb6319..e894235 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -129,23 +129,20 @@ impl CircuitVerifier for DigitSumCircuit { mod tests { use halo2_proofs::{dev::MockProver, pasta::Fp}; - use crate::DigitSumPublicStatement; + use crate::DigitSumPublicInput; use super::*; #[test] - fn test_digit_sum_circuit_proof_succeeds_if_valid_statement() { + fn test_digit_sum_circuit_proof_succeeds_if_valid_public_input() { let secret_witness_number = 12340000; - let public_statement_digitsum = 10; + let public_input_digitsum = 10; let circuit = DigitSumCircuit::::new(secret_witness_number).unwrap(); let prover = MockProver::run( circuit.k, &circuit, - vec![vec![DigitSumPublicStatement::new( - public_statement_digitsum, - ) - .into()]], + vec![vec![DigitSumPublicInput::new(public_input_digitsum).into()]], ) .unwrap(); @@ -153,18 +150,15 @@ mod tests { } #[test] - fn test_digit_sum_circuit_proof_fails_if_invalid_statement() { + fn test_digit_sum_circuit_proof_fails_if_invalid_public_input() { let secret_witness_number = 10000000; - let public_statement_digitsum = 2; + let public_input_digitsum = 2; let circuit = DigitSumCircuit::::new(secret_witness_number).unwrap(); let prover = MockProver::run( circuit.k, &circuit, - vec![vec![DigitSumPublicStatement::new( - public_statement_digitsum, - ) - .into()]], + vec![vec![DigitSumPublicInput::new(public_input_digitsum).into()]], ) .unwrap(); diff --git a/src/commands/mod.rs b/src/commands/mod.rs index f8cff72..d36974d 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,6 +1,6 @@ //! The command module contains the command line interface for the digit sum circuit: -//! - `prove` generates a proof for a given number (witness) and digit sum (statement) -//! - `verify` verifies a proof for a given number (witness) and digit sum (statement) +//! - `prove` generates a proof for a given number (witness) and digit sum (public input) +//! - `verify` verifies a proof for a given number (witness) and digit sum (public input) //! - `graph` generates a graph representation of the circuit mod graph; diff --git a/src/commands/prove.rs b/src/commands/prove.rs index facd36c..7cd334f 100644 --- a/src/commands/prove.rs +++ b/src/commands/prove.rs @@ -10,9 +10,9 @@ pub struct ProveCommand { #[clap(long, short = 'w')] witness: u64, - /// Public number that Bob knows and which represents the sum of the digits of the witness (a.k.a. the statement). - #[clap(long, short = 's')] - statement: u64, + /// Public number that Bob knows and which represents the sum of the digits of the witness (a.k.a. the public input). + #[clap(long, short = 'p')] + public_input: u64, /// Proof export filename. #[clap(long, default_value = "proof.hex")] @@ -28,7 +28,7 @@ impl ProveCommand { pub fn execute(&self) -> StdResult<()> { let secret_witness_number = self.witness; let circuit = DigitSumCircuit::::new(secret_witness_number)?; - let proof = circuit.prove(&[self.statement.into()])?; + let proof = circuit.prove(&[self.public_input.into()])?; let proof_hex = hex::encode(proof); let proof_export_path = self.proof_export_dir.join(&self.proof_file_name); diff --git a/src/commands/verify.rs b/src/commands/verify.rs index f553d94..0e3bdd8 100644 --- a/src/commands/verify.rs +++ b/src/commands/verify.rs @@ -7,9 +7,9 @@ use crate::{CircuitVerifier, DigitSumCircuit, StdResult}; #[derive(Parser, Debug, Clone)] pub struct VerifyCommand { - /// Public number that Bob knows and which represents the sum of the digits of the witness (a.k.a. the statement). - #[clap(long, short = 's')] - statement: u64, + /// Public number that Bob knows and which represents the sum of the digits of the witness (a.k.a. the public input). + #[clap(long, short = 'p')] + public_input: u64, /// Proof import filename. #[clap(long, default_value = "proof.hex")] @@ -28,7 +28,7 @@ impl VerifyCommand { let proof = hex::decode(proof)?; let circuit = DigitSumCircuit::::default(); - circuit.verify(&[self.statement.into()], &proof)?; + circuit.verify(&[self.public_input.into()], &proof)?; println!(">> Proof verified!"); Ok(()) diff --git a/src/lib.rs b/src/lib.rs index f30fe98..dd6148c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ //! The development of the circuit is split into two modules: //! - `digitsum` contains the implementation of the digit sum circuit. //! - `circuit` contains the final circuit that uses one or more chips to implement the desired proof system. -//! - `model` contains the public statement and secret witness types for the digit sum circuit. +//! - `model` contains the public input and secret witness types for the digit sum circuit. //! - `command` contains the command line interface for the digit sum circuit. //! - `proof_system` contains the proof system implementation for the digit sum circuit. diff --git a/src/model.rs b/src/model.rs index 644715a..675609b 100644 --- a/src/model.rs +++ b/src/model.rs @@ -81,21 +81,21 @@ impl TryFrom> for [Value; NUMBER_LENG } } -/// The public statement for the digit sum circuit +/// The public input for the digit sum circuit #[derive(Clone, Debug)] -pub struct DigitSumPublicStatement { +pub struct DigitSumPublicInput { number: u64, } -impl DigitSumPublicStatement { - /// Creates a new public statement +impl DigitSumPublicInput { + /// Creates a new public input pub fn new(number: u64) -> Self { Self { number } } } -impl From for Fp { - fn from(other: DigitSumPublicStatement) -> Fp { +impl From for Fp { + fn from(other: DigitSumPublicInput) -> Fp { Fp::from(other.number) } }