-
Notifications
You must be signed in to change notification settings - Fork 533
Support P256 keys & did:keys #3442
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a9862d2
management of p256 keys seems to work. signing/verify broke
gmulhearn-anonyome 460c6b0
jwt signing
gmulhearn-anonyome dd7bef4
Merge branch 'main' into gm/p256-w3c
gmulhearn-anonyome e073db1
add context to did key p256 docs
gmulhearn-anonyome c6ea8e4
fmt
gmulhearn-anonyome 5ba4f82
small test fix
gmulhearn-anonyome e151706
testing fixes
gmulhearn-anonyome a2e17fc
lint
gmulhearn-anonyome 24df30b
add did key p256 tests
gmulhearn-anonyome b3399cf
revert supported vm types change
gmulhearn-anonyome c0f5152
testing jwt and key manage for p256
gmulhearn-anonyome 0cbde15
Merge branch 'main' into gm/p256-w3c
gmulhearn-anonyome f7dbe65
re review comments
gmulhearn-anonyome 46265e0
typo
gmulhearn-anonyome e742e52
re review
gmulhearn-anonyome 2f49821
revert back SUPPORTED_VERIFICATION_METHOD_TYPES for now
gmulhearn-anonyome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| from unittest import TestCase | ||
|
|
||
| from ...wallet.key_type import P256 | ||
| from ...wallet.util import b58_to_bytes | ||
| from ..did_key import DID_KEY_RESOLVERS, DIDKey | ||
| from .test_dids import DID_P256_zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169 | ||
|
|
||
| TEST_P256_BASE58_KEY = "23FF9c3MrW7NkEW6uNDvdSKQMJ4YFTBXNMEPytZfYeE33" | ||
| TEST_P256_FINGERPRINT = "zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169" | ||
| TEST_P256_DID = f"did:key:{TEST_P256_FINGERPRINT}" | ||
| TEST_P256_KEY_ID = f"{TEST_P256_DID}#{TEST_P256_FINGERPRINT}" | ||
| TEST_P256_PREFIX_BYTES = b"".join([b"\x80\x24", b58_to_bytes(TEST_P256_BASE58_KEY)]) | ||
|
|
||
|
|
||
| class TestDIDKey(TestCase): | ||
| def test_p256_from_public_key(self): | ||
| key_bytes = b58_to_bytes(TEST_P256_BASE58_KEY) | ||
| did_key = DIDKey.from_public_key(key_bytes, P256) | ||
|
|
||
| assert did_key.did == TEST_P256_DID | ||
|
|
||
| def test_p256_from_public_key_b58(self): | ||
| did_key = DIDKey.from_public_key_b58(TEST_P256_BASE58_KEY, P256) | ||
|
|
||
| assert did_key.did == TEST_P256_DID | ||
|
|
||
| def test_p256_from_fingerprint(self): | ||
| did_key = DIDKey.from_fingerprint(TEST_P256_FINGERPRINT) | ||
|
|
||
| assert did_key.did == TEST_P256_DID | ||
| assert did_key.public_key_b58 == TEST_P256_BASE58_KEY | ||
|
|
||
| def test_p256_from_did(self): | ||
| did_key = DIDKey.from_did(TEST_P256_DID) | ||
|
|
||
| assert did_key.public_key_b58 == TEST_P256_BASE58_KEY | ||
|
|
||
| def test_p256_properties(self): | ||
| did_key = DIDKey.from_did(TEST_P256_DID) | ||
|
|
||
| assert did_key.fingerprint == TEST_P256_FINGERPRINT | ||
| assert did_key.did == TEST_P256_DID | ||
| assert did_key.public_key_b58 == TEST_P256_BASE58_KEY | ||
| assert did_key.public_key == b58_to_bytes(TEST_P256_BASE58_KEY) | ||
| assert did_key.key_type == P256 | ||
| assert did_key.key_id == TEST_P256_KEY_ID | ||
| assert did_key.prefixed_public_key == TEST_P256_PREFIX_BYTES | ||
|
|
||
| def test_p256_diddoc(self): | ||
| did_key = DIDKey.from_did(TEST_P256_DID) | ||
|
|
||
| resolver = DID_KEY_RESOLVERS[P256] | ||
|
|
||
| assert resolver(did_key) == did_key.did_doc | ||
|
|
||
| def test_p256_resolver(self): | ||
| did_key = DIDKey.from_did(TEST_P256_DID) | ||
| resolver = DID_KEY_RESOLVERS[P256] | ||
| did_doc = resolver(did_key) | ||
|
|
||
| assert did_doc == DID_P256_zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.