Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/royal-markets/eth-signature-verifier
Universal Etheruem signature verification with ERC-6492
https://github.com/royal-markets/eth-signature-verifier
erc1271 erc6492 ethereum
Last synced: 19 days ago
JSON representation
Universal Etheruem signature verification with ERC-6492
- Host: GitHub
- URL: https://github.com/royal-markets/eth-signature-verifier
- Owner: royal-markets
- License: other
- Created: 2024-07-18T16:22:33.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-14T13:02:43.000Z (5 months ago)
- Last Synced: 2024-08-15T03:58:53.869Z (5 months ago)
- Topics: erc1271, erc6492, ethereum
- Language: Rust
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Universal Etheruem signature verification with ERC-6492
This crate verifies any Ethereum signature including:
- EOAs
- Smart contract wallets with [ERC-1271](https://eips.ethereum.org/EIPS/eip-1271)
- Predeploy contract wallets with [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492)## Usage
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::providers::{network::Ethereum, ReqwestProvider};
use eth_signature_verifier::verify_signature;#[tokio::main]
async fn main() {
let address = address!("0xc0ffee254729296a45a3885639AC7E10F9d54979");
let message = "coffee";
let signature = bytes!("0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658");
let provider = ReqwestProvider::::new_http("https://rpc.example.com");let verification = verify_signature(signature, address, message, provider).await.unwrap();
if verification.is_valid() {
// signature valid
}
}
```This crate also allows for the extracting of an address from a signature, as shown below:
```rust
use eth_signature_verifier::extract_address;#[tokio::main]
async fn main() {
let signature = bytes!("0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658")
let address = extract_address(signature).await.unwrap(); // works for EOA, ERC1271, ERC6492
dbg!(address);
}
```See test cases in `src/lib.rs` for more examples.