Skip to content

Commit 62d74b8

Browse files
chore: add comprehensive docstring to compress_with_cryptography (hiero-ledger#1632)
Signed-off-by: Ashhar Ahmad Khan <145142826+AshharAhmadKhan@users.noreply.github.com> Signed-off-by: Ashhar Ahmad Khan <itzashhar@gmail.com>
1 parent d68b248 commit 62d74b8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
132132
- Add automated bot to recommend next issues to contributors after their first PR merge (#1380)
133133
- Added dry-run support and refactored `.github/workflows/bot-workflows.yml` to use dedicated script `.github/scripts/bot-workflows.js` for improved maintainability and testability. (`#1288`)
134134

135+
### Documentation
136+
- Added comprehensive docstring to `compress_with_cryptography` function (#1626)
137+
135138
### Changed
136139
- Refactored `examples/consensus/topic_create_transaction.py` to use `Client.from_env()` (#1611)
137140
- Updated GitHub Actions setup-node action to v6.2.0.

src/hiero_sdk_python/utils/crypto_utils.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,21 @@ def decompress_point(data: bytes) -> Tuple[int, int]:
5656

5757
def compress_with_cryptography(encoded: bytes) -> bytes:
5858
"""
59-
Takes either a 33-byte compressed or 65-byte uncompressed,
60-
returns a 33-byte compressed via cryptography.
59+
Compress an elliptic curve public key to SEC1 compressed format.
60+
61+
Accepts either a 33-byte compressed or 65-byte uncompressed secp256k1
62+
public key and returns the 33-byte compressed representation using
63+
the cryptography library.
64+
65+
Args:
66+
encoded: A secp256k1 public key in either compressed (33 bytes)
67+
or uncompressed (65 bytes) SEC1 format.
68+
69+
Returns:
70+
bytes: The 33-byte compressed public key.
71+
72+
Raises:
73+
ValueError: If the input is not a valid SEC1 encoded point.
6174
"""
6275
pub = ec.EllipticCurvePublicKey.from_encoded_point(SECP256K1_CURVE, encoded)
6376
compressed = pub.public_bytes(

0 commit comments

Comments
 (0)