Skip to content

Commit 80dda63

Browse files
authored
xmss secret key: simplify some fields (leanEthereum#203)
1 parent 390a30d commit 80dda63

2 files changed

Lines changed: 4 additions & 15 deletions

File tree

src/lean_spec/subspecs/xmss/containers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class SecretKey(StrictBaseModel):
374374
`sqrt(LIFETIME)`, with a minimum of `2 * sqrt(LIFETIME)`.
375375
"""
376376

377-
top_tree: HashSubTree | None = None
377+
top_tree: HashSubTree
378378
"""
379379
The top tree containing the root and top `LOG_LIFETIME/2` layers.
380380
@@ -394,15 +394,15 @@ class SecretKey(StrictBaseModel):
394394
395395
"""
396396

397-
left_bottom_tree: HashSubTree | None = None
397+
left_bottom_tree: HashSubTree
398398
"""
399399
The left bottom tree in the sliding window.
400400
401401
This covers epochs:
402402
[left_bottom_tree_index * sqrt(LIFETIME), (left_bottom_tree_index + 1) * sqrt(LIFETIME))
403403
"""
404404

405-
right_bottom_tree: HashSubTree | None = None
405+
right_bottom_tree: HashSubTree
406406
"""
407407
The right bottom tree in the sliding window.
408408

src/lean_spec/subspecs/xmss/interface.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,6 @@ def sign(self, sk: SecretKey, epoch: Uint64, message: bytes) -> Signature:
359359
# With top-bottom tree traversal, we use combined_path to merge paths from
360360
# the bottom tree and top tree.
361361

362-
# Ensure we have the required top-bottom tree structures.
363-
if sk.top_tree is None:
364-
raise ValueError(
365-
"Secret key is missing top-bottom tree structures. "
366-
"This may be a legacy key format that is no longer supported."
367-
)
368-
369362
# Determine which bottom tree contains this epoch.
370363
leafs_per_bottom_tree = 1 << (config.LOG_LIFETIME // 2)
371364
boundary = (sk.left_bottom_tree_index + Uint64(1)) * Uint64(leafs_per_bottom_tree)
@@ -548,12 +541,8 @@ def advance_preparation(self, sk: SecretKey) -> SecretKey:
548541
A new SecretKey with the advanced preparation window.
549542
550543
Raises:
551-
ValueError: If the secret key is missing top-bottom tree structures
552-
or if advancing would exceed the activation interval.
544+
ValueError: If advancing would exceed the activation interval.
553545
"""
554-
if sk.left_bottom_tree is None or sk.right_bottom_tree is None:
555-
raise ValueError("Secret key missing bottom tree data")
556-
557546
leafs_per_bottom_tree = 1 << (self.config.LOG_LIFETIME // 2)
558547

559548
# Check if advancing would exceed the activation interval

0 commit comments

Comments
 (0)