Skip to content

Commit c5d8ee1

Browse files
authored
Merge pull request #78 from bsv-blockchain/feature/auth/certificates-port
Feature/auth/certificates port
2 parents 03983c2 + d8e65d4 commit c5d8ee1

13 files changed

+652
-41
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77
## Table of Contents
88

99
- [Unreleased](#unreleased)
10+
- [1.0.8 - 2025-08-13](#108---2025-08-13)
1011
- [1.0.7.1- 2025-07-28](#1071---2025-07-28)
1112
- [1.0.7- 2025-07-28](#107---2025-07-28)
1213
- [1.0.6.1- 2025-07-03](#1061---2025-07-03)
@@ -43,6 +44,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4344
### Security
4445
- (Notify of any improvements related to security vulnerabilities or potential risks.)
4546

47+
---
48+
## [1.0.8] - 2025-08-13
49+
50+
### Security
51+
- Applied measures for vulnerability reported on [ts-sdk#334](https://github.com/bsv-blockchain/ts-sdk/issues/334).
52+
4653

4754
---
4855
## [1.0.7.1] - 2025-07-28

bsv/__init__.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
from .broadcasters import *
2-
from .broadcaster import *
3-
from .chaintrackers import *
4-
from .chaintracker import *
5-
from .constants import *
6-
from .curve import *
7-
from .fee_models import *
8-
from .fee_model import *
9-
from .script import *
10-
from .hash import *
11-
from .utils import *
12-
from .transaction_preimage import *
13-
from .http_client import HttpClient, default_http_client
14-
from .keys import verify_signed_text, PublicKey, PrivateKey
15-
from .merkle_path import MerklePath, MerkleLeaf
16-
from .transaction import Transaction, InsufficientFunds
17-
from .transaction_input import TransactionInput
18-
from .transaction_output import TransactionOutput
19-
from .encrypted_message import *
20-
from .signed_message import *
1+
"""bsv Python SDK package minimal initializer.
212
3+
Avoid importing heavy submodules at package import time to prevent circular imports
4+
and reduce side effects. Import submodules explicitly where needed, e.g.:
5+
from bsv.keys import PrivateKey
6+
from bsv.auth.peer import Peer
7+
"""
228

23-
__version__ = '1.0.7.1'
9+
__version__ = '1.0.8'
10+
11+
# Optionally expose convenient factories later if needed.

bsv/auth/auth_message.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# auth_message.py - Ported from AuthMessage.py for PEP8 compliance
2+
from typing import List, Optional, Any
3+
from bsv.keys import PublicKey
4+
5+
6+
class AuthMessage:
7+
"""Represents a message exchanged during the auth protocol."""
8+
9+
def __init__(
10+
self,
11+
version: str = "",
12+
message_type: str = "",
13+
identity_key: Optional[PublicKey] = None,
14+
nonce: str = "",
15+
initial_nonce: str = "",
16+
your_nonce: str = "",
17+
certificates: Optional[List[Any]] = None, # Should be List[VerifiableCertificate]
18+
requested_certificates: Optional[Any] = None, # Should be RequestedCertificateSet
19+
payload: Optional[bytes] = None,
20+
signature: Optional[bytes] = None,
21+
):
22+
self.version = version
23+
self.message_type = message_type
24+
self.identity_key = identity_key
25+
self.nonce = nonce
26+
self.initial_nonce = initial_nonce
27+
self.your_nonce = your_nonce
28+
self.certificates = certificates if certificates is not None else []
29+
self.requested_certificates = requested_certificates
30+
self.payload = payload
31+
self.signature = signature

bsv/auth/cert_encryption.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import Tuple, Optional
2+
3+
4+
def get_certificate_encryption_details(field_name: str, serial_number: Optional[str]) -> Tuple[dict, str]:
5+
"""
6+
TS/Go準拠の証明書フィールド暗号化メタデータを返す。
7+
- protocol_id: {'protocol': 'certificate field encryption', 'security_level': 1}
8+
- key_id: serial_numberがあれば "{serial_number} {field_name}", なければ field_name
9+
"""
10+
protocol_id = {
11+
"protocol": "certificate field encryption",
12+
"security_level": 1,
13+
}
14+
if serial_number:
15+
key_id = f"{serial_number} {field_name}"
16+
else:
17+
key_id = field_name
18+
return protocol_id, key_id
19+
20+

0 commit comments

Comments
 (0)