Skip to content

Commit

Permalink
fix conversion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fairingrey committed Jan 14, 2022
1 parent ec4c007 commit 9dbab74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions did-webkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ssi = { version = "0.3", path = "../", features = [
], default-features = false }
async-trait = "0.1"
reqwest = { version = "0.11", features = ["json"] }
hex = "0.4"
http = "0.2"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
28 changes: 21 additions & 7 deletions did-webkey/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ use core::str::FromStr;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};

#[cfg(all(not(target_arch = "wasm32"), feature = "sequoia-openpgp"))]
#[cfg(all(
not(target_arch = "wasm32"),
feature = "sequoia-openpgp",
not(feature = "pgp")
))]
use openpgp::{
cert::prelude::*,
parse::{PacketParser, Parse},
Expand All @@ -15,7 +19,11 @@ use pgp::{
errors::Error as PgpError,
types::KeyTrait,
};
#[cfg(all(not(target_arch = "wasm32"), feature = "sequoia-openpgp"))]
#[cfg(all(
not(target_arch = "wasm32"),
feature = "sequoia-openpgp",
not(feature = "pgp")
))]
use sequoia_openpgp as openpgp;
use sshkeys::PublicKeyKind;
use ssi::did::{DIDMethod, Document, VerificationMethod, VerificationMethodMap, DIDURL};
Expand Down Expand Up @@ -52,7 +60,11 @@ impl FromStr for DIDWebKeyType {
}
}

#[cfg(all(not(target_arch = "wasm32"), feature = "sequoia-openpgp"))]
#[cfg(all(
not(target_arch = "wasm32"),
feature = "sequoia-openpgp",
not(feature = "pgp")
))]
fn parse_pubkeys_gpg(
did: &str,
bytes: Vec<u8>,
Expand All @@ -77,7 +89,11 @@ fn parse_pubkeys_gpg(
Ok((vm_maps, did_urls))
}

#[cfg(all(not(target_arch = "wasm32"), feature = "sequoia-openpgp"))]
#[cfg(all(
not(target_arch = "wasm32"),
feature = "sequoia-openpgp",
not(feature = "pgp")
))]
fn gpg_pk_to_vm(did: &str, cert: Cert) -> Result<(VerificationMethodMap, DIDURL), String> {
let vm_url = DIDURL {
did: did.to_string(),
Expand Down Expand Up @@ -144,9 +160,7 @@ fn gpg_pk_to_vm(
did: &str,
key: SignedPublicKey,
) -> Result<(VerificationMethodMap, DIDURL), String> {
// BUG: Can't convert to UTF-8 here
let fingerprint: String = String::from_utf8(key.fingerprint())
.map_err(|e| format!("Error converting fingerprint to utf8: {}", e))?;
let fingerprint: String = hex::encode_upper(key.fingerprint());

let vm_url = DIDURL {
did: did.to_string(),
Expand Down

0 comments on commit 9dbab74

Please sign in to comment.