1 unstable release
new 0.1.0 | Apr 25, 2025 |
---|
#12 in #stronghold
36KB
382 lines
signer-stronghold
An Ethereum signer for a Stronghold.
What is a Stronghold?
From the documentation:
The Stronghold is a secure storage for sensitive data. Secrets that are stored inside a Stronghold can never be read, but only be accessed via cryptographic procedures. Data inside a Stronghold is heavily protected by the
Runtime
by either being encrypted at rest, having kernel supplied memory guards, that prevent memory dumps, or a combination of both. The Stronghold also persists data written into a Stronghold by creating Snapshots of the current state. The Snapshot itself is encrypted and can be accessed by a key.
Usage
## treat this environment variable with the same care as a private key
export PASSPHRASE=$(openssl rand -hex 48) # or whatever you want
Basic Usage
use signer_stronghold::StrongholdSigner;
let chain_id = Some(1);
let signer = StrongholdSigner::new(chain_id).unwrap();
let message = vec![0, 1, 2, 3];
let sig = signer.sign_message(&message).await.unwrap();
assert_eq!(sig.recover_address_from_msg(message).unwrap(), signer.address());
With Custom Path
use signer_stronghold::StrongholdSigner;
use std::path::PathBuf;
let chain_id = Some(1);
let custom_path = PathBuf::from("/path/to/my_custom.stronghold");
let signer = StrongholdSigner::new_from_path(custom_path, chain_id).unwrap();
// Use signer just like the default one
let message = vec![0, 1, 2, 3];
let sig = signer.sign_message(&message).await.unwrap();
License
This project is licensed under the MIT License - see the LICENSE-MIT file for details.
Dependencies
~41–71MB
~1M SLoC