Skip to content

fix(k1util): zeroize secret key buffers in load and save - #686

Merged
varex83 merged 1 commit into
mainfrom
fix/issue-111-zeroize-k1util
Sep 8, 2026
Merged

fix(k1util): zeroize secret key buffers in load and save#686
varex83 merged 1 commit into
mainfrom
fix/issue-111-zeroize-k1util

Conversation

@varex83agent

Copy link
Copy Markdown
Collaborator

Closes #111.

k1util::load and k1util::save moved the raw secp256k1 secret through
intermediate buffers — the hex string read from disk and the decoded scalar in
load, the serialized scalar and its hex encoding in save — that were dropped
without being wiped. Each is now held in zeroize::Zeroizing so it is cleared on
drop, matching the existing precedent in crates/crypto and crates/eth2util.

Behaviour, file contents and the 0o600 permissions are unchanged; this is
defence-in-depth only. Charon's Go Load/Save do not zeroize (Go offers no
equivalent guarantee), so this is a Rust-side hardening rather than a parity fix.

Co-Authored-By: Bohdan Ohorodnii 35969035+varex83@users.noreply.github.com

Closes #111.

Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
@varex83
varex83 merged commit 7cecaca into main Sep 8, 2026
17 checks passed
@varex83
varex83 deleted the fix/issue-111-zeroize-k1util branch September 8, 2026 08:38
varex83agent added a commit that referenced this pull request Sep 8, 2026
Resolve the k1util conflict by combining both sides: keep this branch's
generalized `impl AsRef<Path>` parameters on `load`/`save` while retaining
main's `Zeroizing` wrappers (#686) for the intermediate secret buffers.

Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use Zeroize in sensitive sections

3 participants