Skip to content
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

feat: ERC5564 Stealth Address scanning #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 83 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"op-bridge",
"remote",
"rollup",
"stealth-addresses"
]
resolver = "2"

Expand All @@ -20,19 +21,24 @@ publish = false
# reth
reth = { git = "https://github.com/paradigmxyz/reth" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth" }
reth-cli-commands = { git = "https://github.com/paradigmxyz/reth" }
reth-cli-runner = { git = "https://github.com/paradigmxyz/reth" }
reth-db = { git = "https://github.com/paradigmxyz/reth" }
reth-discv5 = { git = "https://github.com/paradigmxyz/reth" }
reth-execution-errors = { git = "https://github.com/paradigmxyz/reth" }
reth-execution-types = { git = "https://github.com/paradigmxyz/reth" }
reth-exex = { git = "https://github.com/paradigmxyz/reth", features = ["serde"] }
reth-network-peers = { git = "https://github.com/paradigmxyz/reth" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth" }
reth-provider = { git = "https://github.com/paradigmxyz/reth" }
reth-revm = { git = "https://github.com/paradigmxyz/reth" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth" }

# alloy
alloy-primitives = "0.7"
alloy-sol-types = { version = "0.7", features = ["json"] }

# async
Expand All @@ -42,6 +48,7 @@ tokio = { version = "1.0", features = ["full"] }
tokio-stream = "0.1"

# misc
clap = "4"
eyre = "0.6"

# testing
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ for new developers.
| [OP Bridge](./op-bridge) | Decodes Optimism deposit and withdrawal receipts from L1 | `cargo run --bin op-bridge -- node` |
| [Remote](./remote) | Emits notifications using a gRPC server, and a consumer that receives them | `cargo run --bin remote-exex -- node` to start Reth node with the ExEx and a gRPC server<br>`cargo run --bin remote-consumer` to start a gRPC client |
| [Rollup](./rollup) | Rollup that derives the state from L1 | `cargo run --bin rollup -- node` |
| [Stealth Addresses](./stealth-addresses) | Scans committed blocks for stealth addresses | `cargo run --bin stealthy` |

#### License

Expand Down
33 changes: 33 additions & 0 deletions stealth-addresses/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "stealth-addresses"
version = "0.0.0"
publish = false
edition.workspace = true
license.workspace = true

[dependencies]
reth.workspace = true
reth-chainspec.workspace = true
reth-cli-commands.workspace = true
reth-cli-runner.workspace = true
reth-db.workspace = true
reth-exex.workspace = true
reth-node-api.workspace = true
reth-node-builder.workspace = true
reth-node-ethereum.workspace = true
reth-tracing.workspace = true
reth-execution-types.workspace = true

alloy-primitives.workspace = true
alloy-sol-types = { workspace = true, features = ["json"] }

k256 = { version = "0.13", default-features = false, features = ["ecdsa"] }
chacha20poly1305 = "0.10.1"

eyre.workspace = true
futures.workspace = true
clap.workspace = true

[[bin]]
name = "stealthy"
path = "src/main.rs"
21 changes: 21 additions & 0 deletions stealth-addresses/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Stealth addresses

Scans committed blocks for stealth addresses according to [ERC5564](https://eips.ethereum.org/EIPS/eip-5564).

## Node

```bash
export VIEW_KEY=0x...
stealthy node
```

## Generation

```bash
Usage: stealthy gen [OPTIONS] <COMMAND>

Commands:
addr Generate a stealth address from a stealth meta address alongside an optional encrypted note
meta Generate a stealth meta address from view and spend private keys
key Generate the stealth address private key from the ephemeral public key and view & spend private keys
```
Comment on lines +5 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we show a full flow of generating the address and using it, including the command outputs?

69 changes: 69 additions & 0 deletions stealth-addresses/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//! CLI definition and entrypoint to executable

use clap::{Parser, Subcommand};
use reth::args::{
utils::{chain_help, chain_value_parser, SUPPORTED_CHAINS},
LogArgs,
};
use reth_chainspec::ChainSpec;
use reth_cli_commands::node::{self, NoArgs};
use reth_cli_runner::CliRunner;
use reth_db::DatabaseEnv;
use reth_node_builder::{NodeBuilder, WithLaunchContext};
use std::{future::Future, sync::Arc};

/// Entrypoint.
#[derive(Debug, Parser)]
pub struct Cli {
/// The command to run
#[command(subcommand)]
command: Commands,

/// The chain this node is running.
///
/// Possible values are either a built-in chain or the path to a chain specification file.
#[arg(
long,
value_name = "CHAIN_OR_PATH",
long_help = chain_help(),
default_value = SUPPORTED_CHAINS[0],
value_parser = chain_value_parser,
global = true,
)]
chain: Arc<ChainSpec>,

#[command(flatten)]
logs: LogArgs,
}

impl Cli {
pub fn run<L, Fut>(mut self, launcher: L) -> eyre::Result<()>
where
L: FnOnce(WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>>>, NoArgs) -> Fut,
Fut: Future<Output = eyre::Result<()>>,
{
// add network name to logs dir
self.logs.log_file_directory =
self.logs.log_file_directory.join(self.chain.chain.to_string());

let _guard = self.logs.init_tracing()?;
Comment on lines +45 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to do it separately here? Node command should already handle it for us I think

let runner = CliRunner::default();
match self.command {
Commands::Node(command) => {
runner.run_command_until_exit(|ctx| command.execute(ctx, launcher))
}
Commands::Generator(command) => runner.run_command_until_exit(|_| command.execute()),
}
}
}

/// Commands to be executed
#[derive(Debug, Subcommand)]
pub enum Commands {
/// Start the node
#[command(name = "node")]
Node(node::NodeCommand<NoArgs>),
/// Generate stealth addresses, meta addresses and stealth address private keys.
#[command(name = "gen")]
Generator(Box<crate::generator::Command>),
}
Loading
Loading