Skip to content

Commit

Permalink
Merge pull request #3 from reown-com/feat/verify-message-hash
Browse files Browse the repository at this point in the history
feat: verify message hash
  • Loading branch information
chris13524 authored Oct 19, 2024
2 parents d2ef86d + e147eb3 commit c8ca974
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 161 deletions.
41 changes: 34 additions & 7 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ license = "MIT OR Apache-2.0"
alloy = { version = "0.3", features = ["contract", "rpc-types"] }

[dev-dependencies]
alloy = { version = "0.3", features = ["signer-local"] }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy.git", rev = "d68a6b7" }
k256 = "0.13"
rand = "0.8"
regex = "1"
tokio = { version = "1", features = ["test-util", "macros", "process"] }
tokio = { version = "1", features = ["full"] }

[build-dependencies]
alloy-primitives = { version = "0.8.0" }
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@ erc6492 = { git = "https://github.com/reown-com/erc6492.git", version = "0.1.0"
This crate uses [Alloy](https://github.com/alloy-rs) and requires an RPC provider in order to verify all signature types.

```rust
use alloy_primitives::{address, bytes, eip191_hash_message};
use alloy_provider::{network::Ethereum, ReqwestProvider};

let address = address!("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
let message = "xxx";
let message = eip191_hash_message("Hello, world!");
let signature = bytes!("aaaa");
let provider = ReqwestProvider::<Ethereum>::new_http("https://rpc.example.com");
let provider = ReqwestProvider::<Ethereum>::new_http("https://rpc.example.com".parse().unwrap());

let verification = verify_signature(signature, address, message, provider).await.unwrap();
if verification.is_valid() {
// signature valid
}
```

See test cases in `src/lib.rs` for more examples.
See doctest on `verify_signature()` and test cases in `src/lib.rs` for more examples.
Loading

0 comments on commit c8ca974

Please sign in to comment.