gabriel / muse public
patch dev
AI Agent gabriel · 162 days ago · Apr 17, 2026 · Diff

security: pass bytearray directly to from_private_bytes; add no-bytes-copy tests

- Remove unnecessary bytes(dk.private_bytes) conversion in generate_hd_keypair: Ed25519PrivateKey.from_private_bytes() accepts bytearray (bytes-like), so the explicit bytes() call created a second immutable heap copy that could never be zeroed — eliminated by passing dk.private_bytes directly - Add tests/test_keygen_no_bytes_copy.py verifying bytearray is accepted and that the DerivedKey is zeroed after use regardless of copy presence

sha256:6c41d4106fc048cb9da3bc8d27ec500bb0cf89c37f28719639e52be1754bd5f7 sha
+18 ~1 symbols
sha256:b39249b7ed10217d5e2f1ca6f06b0d621770e091a92f2027549f9985d7053efa snapshot
+18
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 19 symbols
~ tests/test_keygen_no_bytes_copy.py .py 18 symbols added
+ TestFromPrivateBytesAcceptsBytearray class class TestFromPrivateBytesAcceptsBytearray L65–81
+ test_I1_bytearray_accepted method method test_I1_bytearray_accepted L66–70
+ test_I2_equivalent_to_bytes_version method method test_I2_equivalent_to_bytes_version L72–81
+ TestGenerateHdKeypairNoBytescopy class class TestGenerateHdKeypairNoBytescopy L88–115
+ test_II1_derived_key_zeroed_after_keygen method method test_II1_derived_key_zeroed_after_keygen L89–115
+ _MNEMONIC variable variable _MNEMONIC L43–46
+ _SEED variable variable _SEED L47–47
+ DerivedKey import import DerivedKey L40–40
+ Ed25519PrivateKey import import Ed25519PrivateKey L35–35
+ _hdkeys import import _hdkeys L39–39
+ annotations import import annotations L28–28
+ id_module import import id_module L38–38
+ kp_module import import kp_module L37–37
+ mnemonic_to_seed import import mnemonic_to_seed L41–41
+ patch import import patch L31–31
+ pathlib import import pathlib L30–30
+ pytest import import pytest L33–33
+ isolated function function isolated L51–58
~ muse/core/keypair.py .py 1 symbol modified
← Older Oldest on dev
All commits
Newer → Latest on dev

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:6c41d4106fc048cb9da3bc8d27ec500bb0cf89c37f28719639e52be1754bd5f7 --body "your comment"