From 098e952a358da6239176fa85edcca47327835310 Mon Sep 17 00:00:00 2001 From: jonas pauli Date: Sat, 25 May 2024 18:42:58 +0200 Subject: [PATCH] fix circuit --- api/src/state.rs | 10 ++++------ client/src/lib.rs | 15 +++++++++++---- client/src/prover.rs | 2 ++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/api/src/state.rs b/api/src/state.rs index 6c9b076..3549e4f 100644 --- a/api/src/state.rs +++ b/api/src/state.rs @@ -103,9 +103,8 @@ impl AppState { }); // create gov id for user for election 1 let create_gov_id_election_one_command = Command::IssueIdentity { - issuer_skey_path: path_to_election_1 - .join("admin".to_string()) - .join("secret_key"), + issuer_id_path: path_to_election_1 + .join("admin".to_string()), user_pkey_path: path_to_election_1.join(username.clone()).join("public_key"), }; run(Cli { @@ -113,9 +112,8 @@ impl AppState { }); // create gov id for user for election 2 let create_gov_id_election_two_command = Command::IssueIdentity { - issuer_skey_path: path_to_election_2 - .join("admin".to_string()) - .join("secret_key"), + issuer_id_path: path_to_election_2 + .join("admin".to_string()), user_pkey_path: path_to_election_2.join(username.clone()).join("public_key"), }; run(Cli { diff --git a/client/src/lib.rs b/client/src/lib.rs index acf7f9d..69da82d 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -32,7 +32,7 @@ pub enum Command { }, IssueIdentity { #[arg(short, long)] - issuer_skey_path: PathBuf, + issuer_id_path: PathBuf, #[arg(short, long)] user_pkey_path: PathBuf, }, @@ -90,15 +90,21 @@ pub fn run(cli: Cli) { .expect(""); } Command::IssueIdentity { - issuer_skey_path, + issuer_id_path, user_pkey_path, } => { let issuer_skey = - SigningKey::from_slice(&fs::read(issuer_skey_path).expect("")).expect(""); + SigningKey::from_slice(&fs::read(issuer_id_path.join("secret_key")).expect("")).expect(""); + + let mut payload = fs::read(&user_pkey_path).expect(""); + payload.append(&mut fs::read(issuer_id_path.join("public_key")).expect("")); + let public_identity: Signature = - issuer_skey.sign(&fs::read(&user_pkey_path).expect("")); + issuer_skey.sign(&payload); + let mut public_identity_out_path = user_pkey_path.clone(); public_identity_out_path.set_file_name("public_identity"); + let verified_user = VerifiedUser { government_public_key: issuer_skey .verifying_key() @@ -107,6 +113,7 @@ pub fn run(cli: Cli) { .to_vec(), public_identity: public_identity.to_bytes().to_vec(), }; + fs::write( public_identity_out_path, serde_json::to_string(&verified_user).expect(""), diff --git a/client/src/prover.rs b/client/src/prover.rs index ef630fd..ed44bfd 100644 --- a/client/src/prover.rs +++ b/client/src/prover.rs @@ -1,3 +1,5 @@ +use std::io::Read; + // These constants represent the RISC-V ELF and the image ID generated by risc0-build. // The ELF is used for proving and the ID is used for verification. use k256::ecdsa::{