-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
key loader: did: jwk: Ditch multibase did keys
Signed-off-by: John Andersen <[email protected]>
- Loading branch information
Showing
7 changed files
with
61 additions
and
255 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -40,5 +40,3 @@ dependencies: | |
- PyJWT==2.8.0 | ||
- werkzeug==2.2.2 | ||
- cwt==2.7.1 | ||
- py-multibase==1.0.3 | ||
- py-multicodec==0.2.1 |
This file contains 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 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 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,39 @@ | ||
import base64 | ||
from typing import List, Tuple | ||
|
||
import cwt | ||
import cwt.algs.ec2 | ||
import pycose | ||
import pycose.keys.ec2 | ||
import cryptography.hazmat.primitives.asymmetric.ec | ||
from cryptography.hazmat.primitives import serialization | ||
|
||
import jwcrypto.jwk | ||
|
||
from scitt_emulator.did_helpers import DID_JWK_METHOD | ||
from scitt_emulator.key_helper_dataclasses import VerificationKey | ||
|
||
|
||
CONTENT_TYPE = "application/jwk+json" | ||
|
||
|
||
def key_loader_format_did_jwk( | ||
unverified_issuer: str, | ||
) -> List[VerificationKey]: | ||
if not unverified_issuer.startswith(DID_JWK_METHOD): | ||
return [] | ||
key = jwcrypto.jwk.JWK.from_json( | ||
base64.urlsafe_b64decode(unverified_issuer[len(DID_JWK_METHOD):]).decode() | ||
) | ||
return [ | ||
VerificationKey( | ||
transforms=[key], | ||
original=key, | ||
original_content_type=CONTENT_TYPE, | ||
original_bytes=unverified_issuer.encode("utf-8"), | ||
original_bytes_encoding="utf-8", | ||
usable=False, | ||
cwt=None, | ||
cose=None, | ||
) | ||
] |
This file was deleted.
Oops, something went wrong.
This file contains 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 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