Files
serai/coins/ethereum/src/contract.rs

37 lines
742 B
Rust
Raw Normal View History

use thiserror::Error;
use eyre::{eyre, Result};
use ethers_providers::{Provider, Http};
2023-11-08 07:52:32 -05:00
use ethers_contract::abigen;
use crate::crypto::ProcessedSignature;
#[derive(Error, Debug)]
pub enum EthereumError {
#[error("failed to verify Schnorr signature")]
VerificationError,
}
2023-11-06 18:12:53 -05:00
abigen!(Schnorr, "./artifacts/Schnorr.sol/Schnorr.json");
pub async fn call_verify(
2023-11-08 07:52:32 -05:00
contract: &Schnorr<Provider<Http>>,
params: &ProcessedSignature,
) -> Result<()> {
if contract
.verify(
params.parity + 27,
params.px.to_bytes().into(),
params.message,
params.s.to_bytes().into(),
params.e.to_bytes().into(),
)
.call()
.await?
{
Ok(())
} else {
Err(eyre!(EthereumError::VerificationError))
}
}