-
Notifications
You must be signed in to change notification settings - Fork 80
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
weird that this clippy error is just showing up now :( maybe try fixing it (removing the dep) |
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() | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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"
a88f14f
to
55ed8f5
Compare
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>
9b411bd
to
04e8133
Compare
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
Signed-off-by: lli <lli@anonyome.com>
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); | ||
|
There was a problem hiding this comment.
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 String
s. 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 unwrap
s 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..]; |
There was a problem hiding this comment.
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>
@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 |
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