-
Notifications
You must be signed in to change notification settings - Fork 392
feat(signer): adds signer-stronghold #2420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tuddman
wants to merge
17
commits into
alloy-rs:main
Choose a base branch
from
tuddman:signer-stronghold
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e74e2b0
feat(signer): adds signer-stronghold
tuddman 3d15e12
fix(deps): aligns Cargo.toml like other alloy signers
tuddman b2a2010
fix(rustdoc): adds rustdoc declaration
tuddman 56d6a47
fix(test): fixes test dependencies
tuddman c9d8b69
fix(deps): fixes one more alloy dep feature (undocumented)
tuddman e30c56b
Merge branch 'main' into signer-stronghold
tuddman 7cb7262
Merge branch 'main' into signer-stronghold
tuddman d41b0e3
Merge branch 'main' into signer-stronghold
mattsse b3971bb
deny
mattsse 39655f1
fmt
mattsse 5d48a03
chore: ci update
mattsse c058446
chore: ci update
mattsse 7808145
chore: ci update
mattsse c9a0db1
Merge remote-tracking branch 'alloy-rs' into signer-stronghold
tuddman cf61eb5
fix compile error. set work_factor to zero
tuddman a814952
Merge branch 'main' into signer-stronghold
tuddman 1db6fa9
Merge branch 'main' into signer-stronghold
tuddman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/target | ||
*.stronghold | ||
*.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "alloy-signer-stronghold" | ||
description = "An Ethereum signer for a Stronghold" | ||
|
||
version.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
exclude.workspace = true | ||
|
||
[dependencies] | ||
alloy-consensus.workspace = true | ||
alloy-network.workspace = true | ||
alloy-primitives = { workspace = true, features = ["k256"] } | ||
alloy-signer.workspace = true | ||
async-trait.workspace = true | ||
iota_stronghold = "2.1.0" | ||
k256 = { version = "0.13.4", features = ["ecdsa"] } | ||
thiserror.workspace = true | ||
|
||
[dev-dependencies] | ||
alloy-network.workspace = true | ||
alloy-provider = { workspace = true, features = ["anvil-api", "debug-api", "hyper"] } | ||
alloy-node-bindings = { workspace = true } | ||
alloy-rpc-types = { workspace = true, features = ["eth"] } | ||
tokio = { workspace = true, features = ["rt", "rt-multi-thread"] } | ||
tracing.workspace = true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Permission is hereby granted, free of charge, to any | ||
person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the | ||
Software without restriction, including without | ||
limitation the rights to use, copy, modify, merge, | ||
publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software | ||
is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice | ||
shall be included in all copies or substantial portions | ||
of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF | ||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR | ||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# signer-stronghold | ||
|
||
An Ethereum [signer](https://docs.rs/alloy-signer/latest/alloy_signer/trait.Signer.html) for a Stronghold. | ||
|
||
## What is a Stronghold? | ||
|
||
From [the documentation](https://github.com/iotaledger/stronghold.rs/blob/iota-stronghold-v2.1.0/client/src/types/stronghold.rs#L77-L82): | ||
|
||
> 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. | ||
|
||
[Learn more here](https://github.com/iotaledger/stronghold.rs/tree/iota-stronghold-v2.1.0) | ||
|
||
|
||
## Usage | ||
|
||
```bash | ||
## treat this environment variable with the same care as a private key | ||
|
||
export PASSPHRASE=$(openssl rand -hex 48) # or whatever you want | ||
``` | ||
|
||
### Basic Usage | ||
|
||
```rust,no_run | ||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
use alloy_signer_stronghold::StrongholdSigner; | ||
use alloy_signer::Signer; | ||
|
||
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()); | ||
Ok(()) | ||
} | ||
``` | ||
|
||
### With Custom Path | ||
|
||
```rust,no_run | ||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
use alloy_signer_stronghold::StrongholdSigner; | ||
use alloy_signer::Signer; | ||
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(); | ||
Ok(()) | ||
} | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE-MIT](LICENSE-MIT) file for details. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![doc = include_str!("../README.md")] | ||
#![doc( | ||
html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg", | ||
html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico" | ||
)] | ||
#![cfg_attr(not(test), warn(unused_crate_dependencies))] | ||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] | ||
|
||
mod signer; | ||
pub use signer::StrongholdSigner; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting a compilation error from this when trying to clean + test.
This fixes that compilation error.