Skip to content

Commit

Permalink
Merge branch 'hyperledger:main' into pstlouis/add-di-support
Browse files Browse the repository at this point in the history
  • Loading branch information
PatStLouis authored Sep 20, 2024
2 parents 2802141 + e50fb6c commit 1df8875
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 230 deletions.
2 changes: 1 addition & 1 deletion aries_cloudagent/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def init_debug(args):
# --debug to use microsoft's visual studio remote debugger
if ENABLE_PTVSD or "--debug" in args:
DAP_HOST = os.getenv("PTVSD_HOST", None) or os.getenv("DAP_HOST", "localhost")
DAP_PORT = os.getenv("PTVSD_PORT", None) or os.getenv("DAP_PORT", 5678)
DAP_PORT = int(os.getenv("PTVSD_PORT", None) or os.getenv("DAP_PORT", 5678))
try:
import debugpy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def to_url(self, base_url: Optional[str] = None) -> str:
"""
c_json = self.to_json()
c_i = bytes_to_b64(c_json.encode("ascii"), urlsafe=True)
c_i = bytes_to_b64(c_json.encode("ascii"), urlsafe=True, pad=False)
result = urljoin(base_url or self.endpoint or "", "?c_i={}".format(c_i))
return result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def to_url(self, base_url: Optional[str] = None) -> str:
"""
c_json = self.to_json()
oob = bytes_to_b64(c_json.encode("ascii"), urlsafe=True)
oob = bytes_to_b64(c_json.encode("ascii"), urlsafe=True, pad=False)
endpoint = None
if not base_url:
for service_item in self.services:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from unittest.mock import ANY

from aries_cloudagent.tests import mock
from aries_cloudagent.wallet.util import pad

from .....connections.models.conn_record import ConnRecord
from .....connections.models.connection_target import ConnectionTarget
Expand Down Expand Up @@ -883,7 +884,8 @@ async def test_create_invitation_goal_code(self):

base64_message = invi_rec.invitation_url.split("=", maxsplit=1)[1]
base64_bytes = base64_message.encode("ascii")
message_bytes = base64.b64decode(base64_bytes)
message_bytes = base64.b64decode(base64_bytes + b"==")
base64.urlsafe_b64decode(pad(base64_message))
data = message_bytes.decode("ascii")
assert data
invite_json = json.loads(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ async def test_from_verification_method_x_no_public_key_base58(self):

with self.assertRaises(LinkedDataProofException) as context:
key_pair.from_verification_method({})
assert "no publicKeyBase58" in str(context.exception)
assert "Unrecognized" in str(context.exception)
16 changes: 13 additions & 3 deletions aries_cloudagent/vc/ld_proofs/crypto/wallet_key_pair.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Key pair based on base wallet interface."""

from typing import List, Optional, Union
from base58 import b58encode

from ....core.profile import Profile
from ....wallet.base import BaseWallet
from ....wallet.key_type import KeyType
from ....wallet.util import b58_to_bytes
from ..error import LinkedDataProofException
from .key_pair import KeyPair
from ....utils.multiformats import multibase, multicodec


class WalletKeyPair(KeyPair):
Expand Down Expand Up @@ -57,15 +59,23 @@ async def verify(self, message: Union[List[bytes], bytes], signature: bytes) ->

def from_verification_method(self, verification_method: dict) -> "WalletKeyPair":
"""Create new WalletKeyPair from public key in verification method."""
if "publicKeyBase58" not in verification_method:
if "publicKeyBase58" in verification_method:
key_material = verification_method["publicKeyBase58"]
elif "sec:publicKeyMultibase" in verification_method:
# verification_method is framed
_, raw_key = multicodec.unwrap(
multibase.decode(verification_method["sec:publicKeyMultibase"]["@value"])
)
key_material = b58encode(raw_key).decode()
else:
raise LinkedDataProofException(
"Unable to set public key from verification method: no publicKeyBase58"
f"Unrecognized verification method type: {verification_method}"
)

return WalletKeyPair(
profile=self.profile,
key_type=self.key_type,
public_key_base58=verification_method["publicKeyBase58"],
public_key_base58=key_material,
)

@property
Expand Down
112 changes: 0 additions & 112 deletions aries_cloudagent/wallet/key_pair.py

This file was deleted.

110 changes: 0 additions & 110 deletions aries_cloudagent/wallet/tests/test_key_pair.py

This file was deleted.

0 comments on commit 1df8875

Please sign in to comment.