-
Notifications
You must be signed in to change notification settings - Fork 220
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
Decrypt encrypted metadata #4667
Decrypt encrypted metadata #4667
Conversation
c95d74c
to
5435a5b
Compare
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.
Thank you! First round of comments. 🤓
5435a5b
to
fe20c90
Compare
0fee12a
to
642f5e2
Compare
-- [TxMetaText base64_1, TxMetaText base64_2, ..., TxMetaText base64_n] | ||
-- (d) add `enc` field with encryption method value 'basic' | ||
toMetadataEncrypted | ||
:: ByteString |
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.
:: ByteString | |
:: Passphrase "lenient" |
This type documents the purpose of the parameter more clearly.
-- (d) update structure | ||
-- (e) decode metadata | ||
fromMetadataEncrypted | ||
:: ByteString |
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.
:: ByteString | |
:: Passphrase "lenient" |
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.
Second round of review. I insist on the separation of concerns. 🤓
After addressing the separation of concerns, I would also like to see property tests for
toMetadataEncrypted pwd . fromMetadataEncrypted pwd = id
fromMetadataEncrypted pwd . toMetadataEncrypted pwd = id
These two properties are vital to the whole feature and we need to cover them with extensive property tests in a way that integration tests cannot achieve.
153408d
to
d9f8a2d
Compare
481cf05
to
099416a
Compare
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.
Much better, thank you! 😊 The new module is much more, well, modular, and also captures the possible error conditions nicely.
But I still have a couple of comments that I would like to see fixed before merging:
isRight encrypted
in the tests — having this here decreases my confidence in the tests unless we also usecover
, fortunately, I don't think that it's necessary here.error
infromMetadaEncrypted
— unfortunately, I think that this case can be hit when the metadata is sufficiently malformed. We need to turn this into aLeft
instead.
See detailed comments.
lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/MetadataEncryptionSpec.hs
Outdated
Show resolved
Hide resolved
lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/MetadataEncryptionSpec.hs
Outdated
Show resolved
Hide resolved
lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/MetadataEncryptionSpec.hs
Outdated
Show resolved
Hide resolved
lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/MetadataEncryptionSpec.hs
Outdated
Show resolved
Hide resolved
lib/primitive/lib/Cardano/Wallet/Primitive/Types/MetadataEncryption.hs
Outdated
Show resolved
Hide resolved
55868d2
to
df60f0c
Compare
df60f0c
to
81231cc
Compare
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.
Thank you! 😊 Good to merge now — but could you squash the commits a little bit?
relocation to primitive 2 relocation to primitive 3 relocation to primitive 4 relocation to primitive 5
adjust unit tests another property
hlint rebase cleanup
improve on unit tests - part 2 improve on unit tests - part 3 and add better error handling
81231cc
to
3027af8
Compare
…points the work accomplished in this PR. Before you submit, don't forget to: CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project configs docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports run scripts specifications test touch.me.CI weeder.dhall Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project configs docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports run scripts specifications test touch.me.CI weeder.dhall Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project configs docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports run scripts specifications test touch.me.CI weeder.dhall Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> Idea is to enable decryption of already encrypted metadata in decodeTransaction. The user specifies passphrase in which metadata was encrypted and the metadata located as in CIP83 is decrypted. The change is added in non-intrusive way. Due to lack of JSON instances exposure in cardano-api the needed functions were added (they are about to be erased when cardano-api exposes `metadataValueFromJsonNoSchema` in next node versions). The heart of solution is `fromMetadataEncrypted`. Api spec was updated. Integration tests expanded to show the case. ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number adp-3348 <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Source commit: b887956
Idea is to enable decryption of already encrypted metadata in decodeTransaction. The user specifies passphrase in which metadata was encrypted and the metadata located as in CIP83 is decrypted. The change is added in non-intrusive way. Due to lack of JSON instances exposure in cardano-api the needed functions were added (they are about to be erased when cardano-api exposes
metadataValueFromJsonNoSchema
in next node versions).The heart of solution is
fromMetadataEncrypted
. Api spec was updated. Integration tests expanded to show the case.Comments
Issue Number
adp-3348