mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 13:39:25 +00:00
37 lines
729 B
Rust
37 lines
729 B
Rust
use thiserror::Error;
|
|
use eyre::{eyre, Result};
|
|
|
|
use ethers_providers::{Provider, Http};
|
|
use ethers_contract::abigen;
|
|
|
|
use crate::crypto::ProcessedSignature;
|
|
|
|
#[derive(Error, Debug)]
|
|
pub enum EthereumError {
|
|
#[error("failed to verify Schnorr signature")]
|
|
VerificationError,
|
|
}
|
|
|
|
abigen!(Schnorr, "./artifacts/Schnorr.abi");
|
|
|
|
pub async fn call_verify(
|
|
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))
|
|
}
|
|
}
|