diff --git a/Cargo.lock b/Cargo.lock index 6326258..dbb3b7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1777,8 +1777,8 @@ dependencies = [ [[package]] name = "indy-vdr" -version = "0.4.1" -source = "git+https://github.com/hyperledger/indy-vdr.git#fbe4b57c6e46bbf334188aabc3ff0e44763007c9" +version = "0.4.2" +source = "git+https://github.com/hyperledger/indy-vdr.git#b33cbf9ddd22c58fe68e9b66fa6bccbfc556077e" dependencies = [ "async-lock 3.3.0", "async-trait", diff --git a/README.md b/README.md index 65943bf..c67c7c6 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Tool for registering a new NYM and it's role on the Indy Ledger Make sure you are using the latest version of stable rust by running `rustup update`. Run `cargo run` to start the app. +You might require cmake to be present depending on your system. + ### Native Locally `cargo run --release` @@ -37,4 +39,8 @@ On Fedora Rawhide you need to run: ### Web Locally -Sadly, for the moment, the zmq library is preventing a webassembly build. +Sadly, for the moment, the zmq library is preventing a webassembly build. + +### Roadmap + +Using a wallet instead of asking for the seed \ No newline at end of file diff --git a/src/app.rs b/src/app.rs index 61525a6..9616211 100644 --- a/src/app.rs +++ b/src/app.rs @@ -10,6 +10,20 @@ pub enum MyRoles { NetworkMonitor = 201, Steward = 2, } + +#[derive(PartialEq, Eq, Deserialize, Serialize, Debug)] +pub enum DIDVersion { + Sov, + Indy, +} +impl DIDVersion { + pub fn to_usize(&self) -> usize { + match self { + DIDVersion::Sov => 1, + DIDVersion::Indy => 2, + } + } +} impl Default for MyRoles { fn default() -> Self { Self::Endorser @@ -33,6 +47,7 @@ pub struct TemplateApp { my_role: MyRoles, nym_did: DidInfo, trustee_did: DidInfo, + did_version: DIDVersion, } impl Default for TemplateApp { @@ -50,6 +65,7 @@ impl Default for TemplateApp { my_role: Default::default(), nym_did: Default::default(), trustee_did: Default::default(), + did_version: DIDVersion::Indy, } } } @@ -127,6 +143,7 @@ impl eframe::App for TemplateApp { &mut self.endorser_seed, &mut self.txn, &mut self.signed_txn_result, + &mut self.did_version, ); }); } @@ -147,6 +164,7 @@ impl eframe::App for TemplateApp { &mut self.my_role, &mut self.nym_did, &mut self.trustee_did, + &mut self.did_version, ); }); } diff --git a/src/helpers.rs b/src/helpers.rs index 44518e7..03f0701 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -7,8 +7,8 @@ use indy_vdr::pool::helpers::perform_ledger_request; use indy_vdr::pool::{PreparedRequest, ProtocolVersion, RequestResult, SharedPool}; use serde_json::Value; -pub fn create_did(seed: String) -> anyhow::Result { - let (did, prv, vk) = generate_did(Some(seed.as_bytes()), Some(1))?; +pub fn create_did(seed: String, version: usize) -> anyhow::Result { + let (did, prv, vk) = generate_did(Some(seed.as_bytes()), Some(version))?; let endorser_did = DidInfo { did: DidValue::from(did.to_string()), privatekey: prv, diff --git a/src/indorser.rs b/src/indorser.rs index 07e7b3f..6a76390 100644 --- a/src/indorser.rs +++ b/src/indorser.rs @@ -1,16 +1,19 @@ +use crate::app::DIDVersion; use crate::helpers::{create_did, sign_transaction}; use egui::Ui; + pub fn endorser_tool( ui: &mut Ui, endorser_seed: &mut String, txn: &mut String, signed_txn_result: &mut Option, + did_version: &mut DIDVersion, ) { ui.label("Sign Txn with Endorser DID"); // Add more UI elements inside the nested window ui.heading("Endorser"); - ui.horizontal(|ui| { + ui.vertical(|ui| { ui.label("Endorser seed: "); ui.add( egui::TextEdit::singleline(endorser_seed) @@ -18,10 +21,17 @@ pub fn endorser_tool( .hint_text("Enter 32 bytes seed"), ); ui.label(format!("Length: {}", endorser_seed.len())); + ui.label("Select the version for the DID. did:Sov is 1, did:Indy is 2"); + egui::ComboBox::from_id_source("version_dropdown") + .selected_text(format!("{:?}", did_version)) + .show_ui(ui, |ui| { + ui.selectable_value(&mut *did_version, DIDVersion::Sov, "SOV"); + ui.selectable_value(&mut *did_version, DIDVersion::Indy, "Indy"); + }); }); ui.separator(); if endorser_seed.len() == 32 { - let endorser_did = create_did(endorser_seed.clone()).unwrap(); + let endorser_did = create_did(endorser_seed.clone(), did_version.to_usize()).unwrap(); ui.colored_label( egui::Color32::KHAKI, format!("DID: {:?}", endorser_did.did.0), diff --git a/src/nym_registration.rs b/src/nym_registration.rs index 3055bc1..d28edec 100644 --- a/src/nym_registration.rs +++ b/src/nym_registration.rs @@ -5,9 +5,10 @@ use indy_vdr::ledger::constants::{LedgerRole, UpdateRole}; use indy_vdr::pool::{PoolBuilder, PoolTransactions}; use rfd::FileDialog; -use crate::app::MyRoles; +use crate::app::{DIDVersion, MyRoles}; use crate::helpers::{create_did, register_nym, DidInfo}; +#[allow(clippy::too_many_arguments)] pub fn nym_registration_tool( ui: &mut Ui, trustee_seed: &mut String, @@ -16,6 +17,7 @@ pub fn nym_registration_tool( my_role: &mut MyRoles, nym_did: &mut DidInfo, trustee_did: &mut DidInfo, + did_version: &mut DIDVersion, ) { ui.heading("Nym Creation Tool"); ui.separator(); @@ -33,8 +35,14 @@ pub fn nym_registration_tool( .hint_text("Enter 32 bytes seed"), ); ui.label(format!("Length: {}", trustee_seed.len())); + ui.label("Select the version used for the trustee DID. did:Sov is 1, did:Indy is 2"); + egui::ComboBox::from_id_source("did_version_dropdown") + .selected_text(format!("{:?}", did_version)) + .show_ui(ui, |ui| { + ui.selectable_value(&mut *did_version, DIDVersion::Sov, "SOV"); + ui.selectable_value(&mut *did_version, DIDVersion::Indy, "Indy"); + }); }); - ui.separator(); ui.vertical(|ui| { ui.heading("NYM Registration"); @@ -62,7 +70,7 @@ pub fn nym_registration_tool( }); ui.separator(); ui.label("Select the role for the NYM"); - egui::ComboBox::from_id_source("my_dropdown") + egui::ComboBox::from_id_source("my_role_dropdown") .selected_text(format!("{:?}", my_role)) .show_ui(ui, |ui| { ui.selectable_value(&mut *my_role, MyRoles::Endorser, "Endorser"); @@ -87,7 +95,7 @@ pub fn nym_registration_tool( MyRoles::Steward => UpdateRole::Set(LedgerRole::Steward), }; - match create_did(trustee_seed.clone()) { + match create_did(trustee_seed.clone(), did_version.to_usize()) { Ok(did) => *trustee_did = did, Err(e) => { eprintln!("Error occurred: {:?}", e);