Skip to content

Commit

Permalink
Remove the id-index argument when recovering from secrets.
Browse files Browse the repository at this point in the history
  • Loading branch information
abizjak committed Feb 20, 2024
1 parent f33c782 commit 7c6576f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
5 changes: 5 additions & 0 deletions recover-id-object/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Unreleased

## 2.0.1

- Remove the id-index argument when recovering from secrets. The generated file
name is just named with a `recovered-from-id-cred-sec` instead of id-index.

## 2.0.0

- Add command to generate secrets and ability to recover from specific secrets only.
Expand Down
2 changes: 1 addition & 1 deletion recover-id-object/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion recover-id-object/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "recover-id-object"
version = "2.0.0"
version = "2.0.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion recover-id-object/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ recover-id-object recover-identity --concordium-wallet <PATH_TO_SEED_PHRASE> --i
To recover with the secrets generated by `generate-secrets`, run:

```bash
recover-id-object recover-identity --prf-key <PRF_KEY> --id-cred-sec <ID_CRED_SEC> --id-index <ID_INDEX> --ip-index ... (* other args *)
recover-id-object recover-identity --prf-key <PRF_KEY> --id-cred-sec <ID_CRED_SEC> --ip-index ... (* other args *)

```

Expand Down
29 changes: 11 additions & 18 deletions recover-id-object/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ struct RecoverIdentityArgs {
/// Location of the seed phrase.
#[clap(
long,
help = "Path to the seed phrase file. Specify either this or --id-cred-sec, --prf-key, and --id-index.",
conflicts_with_all = ["prf_key", "id_cred_sec", "id_index"],
required_unless_present_all = ["prf_key", "id_cred_sec", "id_index"]
help = "Path to the seed phrase file. Specify either this or --id-cred-sec, --prf-key.",
conflicts_with_all = ["prf_key", "id_cred_sec"],
required_unless_present_all = ["prf_key", "id_cred_sec"]
)]
concordium_wallet: Option<std::path::PathBuf>,
#[clap(long = "ip-index", help = "Identity of the identity provider.")]
Expand All @@ -89,23 +89,16 @@ struct RecoverIdentityArgs {
long,
help = "Hex encoded id credential secret. Specify either this or --concordium-wallet.",
required_unless_present = "concordium_wallet",
requires_all = ["prf_key", "id_index"]
requires_all = ["prf_key"]
)]
id_cred_sec: Option<String>,
#[clap(
long,
help = "Hex encoded PRF key. Specify either this or --concordium-wallet.",
required_unless_present = "concordium_wallet",
requires_all = ["id_cred_sec", "id_index"]
requires_all = ["id_cred_sec"]
)]
prf_key: Option<String>,
#[clap(
long,
help = "Identity index of account to recover. Specify either this or --concordium-wallet.",
required_unless_present = "concordium_wallet",
requires_all = ["id_cred_sec", "prf_key"]
)]
id_index: Option<u32>,
#[clap(long, help = "Network to recover on.", default_value = "testnet")]
network: key_derivation::Net,
}
Expand Down Expand Up @@ -259,7 +252,6 @@ async fn recover_identity(
base16_decode_string(&recovery_args.prf_key.context("Missing prf_key")?)?;
let id_cred_sec: PedersenValue<ArCurve> =
base16_decode_string(&recovery_args.id_cred_sec.context("Missing prf_key")?)?;
let id_index = recovery_args.id_index.context("Missing id_index")?;

recover_from_secrets(
&mut concordium_client,
Expand All @@ -268,7 +260,7 @@ async fn recover_identity(
&crypto_params,
prf_key,
id_cred_sec,
id_index,
"recovered-from-id-cred-sec",
)
.await
.context("Could not recover identity")
Expand Down Expand Up @@ -330,7 +322,8 @@ async fn recover_from_secrets(
crypto_params: &GlobalContext<ArCurve>,
prf_key: PrfKey,
id_cred_sec: PedersenValue<ArCurve>,
id_index: u32,
id_description: impl std::fmt::Display, /* description of the identity, e.g., index of the
* identity. */
) -> anyhow::Result<()> {
let request = generate_id_recovery_request(
&id.ip_info,
Expand All @@ -357,15 +350,15 @@ async fn recover_from_secrets(

let id_object: Versioned<IdentityObjectV1<IpPairing, ArCurve, AttributeKind>> =
response.json().await?;
let id_descr = id_description.to_string();
std::fs::write(
format!("{}-{id_index}.json", id.ip_info.ip_identity.0),
format!("{}-{id_description}.json", id.ip_info.ip_identity.0),
serde_json::to_string_pretty(&serde_json::json!({
"identityIndex": id_index,
"ipInfo": &id.ip_info,
"idObject": id_object.value
}))?,
)?;
println!("Got identity object for index {id_index}.");
println!("Got identity object for index {id_descr}.");

// Print all accounts for this identity.
let mut acc_fail_count = 0;
Expand Down

0 comments on commit 7c6576f

Please sign in to comment.