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

DID Support #498

Merged
merged 34 commits into from
Dec 4, 2023
Merged

DID Support #498

merged 34 commits into from
Dec 4, 2023

Conversation

nkramer44
Copy link
Collaborator

@nkramer44 nkramer44 commented Nov 28, 2023

Fixes #496. Adds XLS-40d DID support.

Includes new transactions:

  • DidSet
  • DidDelete

Includes new ledger enty:

  • DidObject

… be base 10, not base 16. Also serialize XChainClaimIds as hex in JSON, and add a new XChainCount type that also serializes to hex in JSON
Add new transactions to SignatureUtils switches
Add attestations that can be signed.
Add ability to sign attestations to signature services.

@Override
public void serialize(DidData DidData, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeString(DidData.value());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this data actually be hex-encoded? The spec shows this as a string in JSON, but in rippled it's just a BLOB.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should be hex encoded, but I'm not currently checking that it is in DidData, DidDocument or DidUri. I could do that, but it adds an extra hex decode, and I've generally stopped adding validation to our models because rippled often breaks those validations. However, if a developer sets one of these fields to a non-hex String and tries to serialize it to sign, the binary codec will throw an error because it's expecting a hex string, so their errors will at least be caught before submitting to rippled.

Copy link
Collaborator

@sappenin sappenin Nov 29, 2023

Choose a reason for hiding this comment

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

Yes, that's reasonable. I'm not too worried in this particular case because the input on line 44 is going to be coming from rippled, and it should be HEX.

On the constructors of these threee (DidData.of(...) it might be worth adding validation that only HEX can be supplied there -- but to you're point, the binary codec will throw. Maybe this relates to #499, and can be fixed there -- but the binary codec errors aren't very helpful.

This isn't a blocker for me here, so if you don't want to do anything for now, I'm good with that (in which case, please "resolve" this comment).

.lastLedgerSequence(sourceAccountInfo.ledgerIndexSafe().unsignedIntegerValue().plus(UnsignedInteger.valueOf(4)))
.signingPublicKey(sourceKeyPair.publicKey())
.data(DidData.of("617474657374"))
.uri(DidUri.of("6469645F6578616D706C65"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does rippled do if this isn't HEX?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See comment above -- I can't actually submit a transaction with a non-hex value for any of these fields because the binary codec will throw an exception.

You could talk me into validating that DidData, DidUri, and DidDocument are hex encoded in those objects so developers get better exceptions...

Copy link
Collaborator

@sappenin sappenin Nov 29, 2023

Choose a reason for hiding this comment

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

Maybe make a comment in #499 to improve the binary codec errors.

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

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

Comparison is base (73d7848) 91.52% compared to head (5b13089) 91.61%.

Files Patch % Lines
...l4j/model/transactions/metadata/MetaDidObject.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #498      +/-   ##
============================================
+ Coverage     91.52%   91.61%   +0.08%     
- Complexity     1748     1774      +26     
============================================
  Files           355      365      +10     
  Lines          4884     4948      +64     
  Branches        403      408       +5     
============================================
+ Hits           4470     4533      +63     
- Misses          281      282       +1     
  Partials        133      133              

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

Base automatically changed from nk/xchain to main December 1, 2023 18:07
@nkramer44 nkramer44 merged commit 774d60f into main Dec 4, 2023
19 checks passed
@nkramer44 nkramer44 deleted the nk/did2 branch December 4, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for DID
2 participants