Skip to content

Commit

Permalink
fix circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas089 committed May 25, 2024
1 parent d1c2035 commit 098e952
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 4 additions & 6 deletions api/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,17 @@ 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 {
command: create_gov_id_election_one_command,
});
// 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 {
Expand Down
15 changes: 11 additions & 4 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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()
Expand All @@ -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(""),
Expand Down
2 changes: 2 additions & 0 deletions client/src/prover.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down

0 comments on commit 098e952

Please sign in to comment.