Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release History
- refactor!: remove deprecated `StrKey.encode_muxed_account` and `StrKey.decode_muxed_account`, use `stellar_sdk.MuxedAccount` instead.
- refactor!: remove `TransactionBuilder.append_create_stellar_asset_contract_from_address_op`, use `TransactionBuilder.append_create_contract_op` instead.
- feat!: add `max_content_size` parameter to `BaseSyncClient.get()` and `BaseAsyncClient.get()` to prevent DoS via memory exhaustion. `fetch_stellar_toml`, `fetch_stellar_toml_async` and federation resolve functions now enforce response size limits. Custom client implementations must update their `get()` signature to include `max_content_size: int | None = None`.
- fix: correct equality checks for `SignedPayloadSigner` and `SignerKey`.
- fix: xdr-generator security hardening:
- validate `Opaque`/`String` max sizes on unpack.
- add remaining-input-length checks for variable-length arrays.
Expand Down
4 changes: 2 additions & 2 deletions stellar_sdk/signer_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __hash__(self):
def __eq__(self, other: object) -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return self.account_id == other.account_id and self.payload == self.payload
return self.account_id == other.account_id and self.payload == other.payload

def __repr__(self):
return f"<SignedPayloadSigner [account_id={self.account_id}, payload={self.payload}]>"
Expand Down Expand Up @@ -249,7 +249,7 @@ def __eq__(self, other: object) -> bool:
return NotImplemented
return (
self.signer_key == other.signer_key
and self.signer_key_type == self.signer_key_type
and self.signer_key_type == other.signer_key_type
)

def __repr__(self):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_signer_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ def test_ed25519_signed_payload(self):
assert SignerKey.ed25519_signed_payload(ed25519_signed_payload) == signer_key
assert SignerKey.ed25519_signed_payload(signer_key_data) == signer_key

def test_eq_compares_signer_key_type(self):
signer_key_data = b"\x85\xba{e\xeb\x92\x83r\xb2\xf5\xc4Z$\xc2\x84b\xc6\x8a\xa6\x04\x86dg$x6\x0c\xeb\x9aW\x13W"
ed25519_signer = SignerKey(
signer_key_data, SignerKeyType.SIGNER_KEY_TYPE_ED25519
)
hash_x_signer = SignerKey(signer_key_data, SignerKeyType.SIGNER_KEY_TYPE_HASH_X)

assert ed25519_signer != hash_x_signer


class TestSignedPayloadSigner:
@pytest.mark.parametrize(
Expand Down Expand Up @@ -253,3 +262,10 @@ def test_to_signed_payload_signer_raise(self):
"<SignerKeyType.SIGNER_KEY_TYPE_ED25519_SIGNED_PAYLOAD: 3>",
):
signer_key.to_signed_payload_signer()

def test_eq_compares_payload(self):
account_id = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ"
signer1 = SignedPayloadSigner(account_id, b"cat")
signer2 = SignedPayloadSigner(account_id, b"dog")

assert signer1 != signer2
Loading