Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #1090 #1091 DID:SOV DIDDoc resolves without a service/endpoint and expands shorthand verkey notation for publicKeyBase58 #1105

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

lukewli-anonyome
Copy link
Contributor

This PR introduces a fix for the DIDDoc resolution error outlined in issue #1090 and the shorthand verkey error outlined in issue #1091.

Closes #1090
Closes #1091

@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2024

Codecov Report

Attention: 31 lines in your changes are missing coverage. Please review.

Comparison is base (7614685) 0.05% compared to head (11828fa) 0.05%.
Report is 8 commits behind head on main.

Files Patch % Lines
aries/aries_vcx/src/common/signing.rs 0.00% 23 Missing ⚠️
...ries/misc/legacy/diddoc_legacy/src/aries/diddoc.rs 0.00% 4 Missing ⚠️
aries/aries_vcx/src/common/credentials/encoding.rs 0.00% 1 Missing ⚠️
...ies/aries_vcx/src/handlers/out_of_band/receiver.rs 0.00% 1 Missing ⚠️
aries/aries_vcx/src/handlers/util.rs 0.00% 1 Missing ⚠️
aries/aries_vcx/src/protocols/did_exchange/mod.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1105      +/-   ##
========================================
- Coverage   0.05%   0.05%   -0.01%     
========================================
  Files        471     478       +7     
  Lines      24093   24334     +241     
  Branches    4332    4370      +38     
========================================
  Hits          13      13              
- Misses     24079   24320     +241     
  Partials       1       1              
Flag Coverage Δ
unittests-aries-vcx 0.05% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gmulhearn-anonyome
Copy link
Contributor

weird that this clippy error is just showing up now :( maybe try fixing it (removing the dep)

Comment on lines 56 to 64
fn expand_abbreviated_verkey(did: &str, verkey: &str) -> String {
if verkey.starts_with('~') {
let did_public_key_part = &did[8..];
format!("{}{}", did_public_key_part, &verkey[1..])
} else {
verkey.to_string()
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this won't exactly work; have a dig around some of the links in the original ticket. Here's a test vector to play with:

  • nym/did: "7Sqc3ne5NfUVxMTrHahxz3"
  • shortened verkey: "~DczaFTexiEYv5abkEUZeZt"
  • expected (expanded) verkey: "4WkksEAXsewRbDYDz66aTdjtVF2LBxbqEMyF2WEjTBKk"

Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Comment on lines 58 to 64
let decoded_did = bs58::decode(did).into_vec().unwrap();
let decoded_stripped_key = bs58::decode(stripped_key).into_vec().unwrap();
let decoded_did_string = String::from_utf8(decoded_did).unwrap();
let decoded_stripped_key_string = String::from_utf8(decoded_stripped_key).unwrap();

let decoded_verkey = format!("{}{}", decoded_did_string, decoded_stripped_key_string);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the biggest fan of treating raw bytes (Vec / &[u8]) as Strings. I think you did this so that you could concatenate the bytes, which is correctly.

The String::from_utf8 is error-prone here, since we aren't necessarily dealing with utf8 bytes, and this will panic if they aren't valid utf8 bytes.

there are other ways to concatenate bytes together (two vec's )

Also in general; avoid unwraps in non-testing code; you might have to make this return a Result

Signed-off-by: lli <lli@anonyome.com>
@@ -53,6 +53,29 @@ fn unix_to_datetime(posix_timestamp: i64) -> Option<DateTime<Utc>> {
.map(|date_time| DateTime::<Utc>::from_naive_utc_and_offset(date_time, Utc))
}

fn expand_abbreviated_verkey(did: &str, verkey: &str) -> Result<String, DidSovError> {
if let Some(stripped_key) = verkey.strip_prefix('~') {
let stripped_did = &did[8..];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bit of a nit pick;

i'd refer if we referred to "stripped_did" as the "nym". i think that term is more widely understood.

also, altho did[8..] would work to remove the did:sov prefix, it isn't very clear that this is what is happening here.

IMO it would be nice if expand_abbreviated_verkey just took in nym rather than did.

then where expand_abbreviated_verkey is called, you'll need to pre-calculate the nym from the did. you might be able to use the ddo_id
Did struct for this actually; it should have a .id() method, which will return the end-part of the DID (aka the NYM)

Signed-off-by: lli <lli@anonyome.com>
@Patrik-Stas
Copy link
Contributor

@lukewli-anonyome @gmulhearn-anonyome I am sorry folks for the conflicts that have arose after finally merging #1097

However, when you have bandwidth feel free to resume this effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants