Skip to content

Commit

Permalink
Remove ethers mono-crate
Browse files Browse the repository at this point in the history
Reduces size of ethereum-serai and gives us clarity on what's used.

Next should be rmeoving the ethers-provided signing code.
  • Loading branch information
kayabaNerve committed Nov 6, 2023
1 parent 205bec3 commit c900387
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 61 deletions.
44 changes: 9 additions & 35 deletions Cargo.lock

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

25 changes: 14 additions & 11 deletions coins/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,28 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
thiserror = "1"
rand_core = "0.6"
thiserror = { version = "1", default-features = false }
eyre = { version = "0.6", default-features = false }

serde_json = "1"
serde = "1"
serde_json = { version = "1", default-features = false, features = ["std"] }

sha2 = "0.10"
sha3 = "0.10"
sha3 = { version = "0.10", default-features = false, features = ["std"] }

group = "0.13"
k256 = { version = "^0.13.1", default-features = false, features = ["std", "arithmetic", "bits", "ecdsa"] }
group = { version = "0.13", default-features = false }
k256 = { version = "^0.13.1", default-features = false, features = ["std", "ecdsa"] }
frost = { package = "modular-frost", path = "../../crypto/frost", features = ["secp256k1", "tests"] }

eyre = "0.6"

ethers = { version = "2", default-features = false, features = ["abigen", "ethers-solc"] }
ethers-core = { version = "2", default-features = false }
ethers-signers = { version = "2", default-features = false }
ethers-middleware = { version = "2", default-features = false }
ethers-providers = { version = "2", default-features = false }
ethers-contract = { version = "2", default-features = false, features = ["abigen", "providers"] }
ethers-solc = { version = "2", default-features = false }

[build-dependencies]
ethers-solc = { version = "2", default-features = false }

[dev-dependencies]
rand_core = { version = "0.6", default-features = false, features = ["std"] }
sha2 = { version = "0.10", default-features = false, features = ["std"] }
tokio = { version = "1", features = ["macros"] }
22 changes: 12 additions & 10 deletions coins/ethereum/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
use crate::crypto::ProcessedSignature;
use ethers::{contract::ContractFactory, prelude::*, solc::artifacts::contract::ContractBytecode};
use eyre::{eyre, Result};
use std::fs::File;
use std::sync::Arc;
use std::{sync::Arc, fs::File};

use thiserror::Error;
use eyre::{eyre, Result};

use ethers_signers::LocalWallet;
use ethers_middleware::SignerMiddleware;
use ethers_providers::{Provider, Http};
use ethers_contract::{abigen, ContractFactory};
use ethers_solc::artifacts::contract::ContractBytecode;

use crate::crypto::ProcessedSignature;

#[derive(Error, Debug)]
pub enum EthereumError {
#[error("failed to verify Schnorr signature")]
VerificationError,
}

abigen!(
Schnorr,
"./artifacts/Schnorr.sol/Schnorr.json",
event_derives(serde::Deserialize, serde::Serialize),
);
abigen!(Schnorr, "./artifacts/Schnorr.sol/Schnorr.json",);

pub async fn deploy_schnorr_verifier_contract(
client: Arc<SignerMiddleware<Provider<Http>, LocalWallet>>,
Expand Down
2 changes: 1 addition & 1 deletion coins/ethereum/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use k256::{
use frost::{algorithm::Hram, curve::Secp256k1};

pub fn keccak256(data: &[u8]) -> [u8; 32] {
Keccak256::digest(data).try_into().unwrap()
Keccak256::digest(data).into()
}

pub fn hash_to_scalar(data: &[u8]) -> Scalar {
Expand Down
8 changes: 4 additions & 4 deletions coins/ethereum/tests/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use rand_core::OsRng;

use ::k256::{elliptic_curve::bigint::ArrayEncoding, U256};

use ethers::{
prelude::*,
utils::{keccak256, Anvil, AnvilInstance},
};
use ethers_core::utils::{keccak256, Anvil, AnvilInstance};
use ethers_middleware::{Middleware, SignerMiddleware};
use ethers_providers::{Provider, Http};
use ethers_signers::LocalWallet;

use frost::{
curve::Secp256k1,
Expand Down

0 comments on commit c900387

Please sign in to comment.