This repository was archived by the owner on Jul 12, 2026. It is now read-only.
Introduce secret accessor flag and zeroize memory during cleanup#204
Open
HudsonGraeme wants to merge 4 commits into
Open
Introduce secret accessor flag and zeroize memory during cleanup#204HudsonGraeme wants to merge 4 commits into
HudsonGraeme wants to merge 4 commits into
Conversation
Keypair::private_key(), ::mnemonic(), ::seed_hex() gated behind the "secret-access" cargo feature. Enabled: pub. Disabled (default): pub(crate). External consumers opt in explicitly; internal serialization in keyfile.rs and wallet.rs compiles unchanged via pub(crate) fallback. Custom Drop impl overwrites private_key, seed_hex, and mnemonic fields via zeroize before deallocation, preventing secret residue in freed heap memory. sr25519::Pair is set to None on drop (does not implement Zeroize). Struct update syntax (..Default::default()) replaced with explicit field initialization to satisfy Rust's move-out restriction on Drop types.
The pair branch returned raw key bytes via to_raw_vec() while the self.private_key branch returned UTF-8 bytes of the hex string via as_bytes(). Downstream serialization in keyfile.rs hex-encodes the result, producing double-encoded output in the fallback path. Both branches now consistently return decoded raw bytes.
…essor-visibility Resolve conflicts in src/keypair.rs by integrating ED25519 multi-crypto support from staging with the zeroize-on-drop secret accessor restriction. Replace ..Default::default() struct-update syntax with explicit field initialization in create_from_mnemonic, create_from_seed, create_from_private_key, create_from_uri, and the encrypted-JSON ED25519 branch to satisfy Rust's move-out restriction on the Drop-implementing Keypair.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
secret-accessflag to opt-in if they need to access those values. This is useful, for example, in subnets where validator code never needs to directly access the private aspects of hotkeys but still requires the ability to sign transactions, read the ss58 and sign payloads.Caution
This is a breaking change for downstream consumers if the build does not explicitly enable the flag. To avoid this, the flag can be added to defaults however it appears to be safer to leave it out.
Branch updated to the latest
stagingwith conflicts resolved. Verified:cargo test(47 passing, default andsecret-accessfeatures) and the Python suite (81 passing across keypair, keyfile, wallet, utils, legacy).