use crate::provider::{Crypto, CryptoError};
#[derive(Debug)]
pub struct NativeCrypto;
impl Crypto for NativeCrypto {
#[cfg(feature = "aws-lc-rs")]
fn secp256r1_verify(&self, msg: &[u8; 32], sig: &[u8; 64], pk: &[u8; 64]) -> bool {
crate::p256_awslc::secp256r1_verify(msg, sig, pk)
}
fn bn254_g1_add(&self, p1: &[u8], p2: &[u8]) -> Result<[u8; 64], CryptoError> {
crate::bn254::g1_add(p1, p2)
}
fn bn254_g1_mul(&self, point: &[u8], scalar: &[u8]) -> Result<[u8; 64], CryptoError> {
crate::bn254::g1_mul(point, scalar)
}
fn bn254_pairing_check(&self, pairs: &[(&[u8], &[u8])]) -> Result<bool, CryptoError> {
crate::bn254::pairing_check(pairs)
}
#[cfg(feature = "std")]
fn modexp(
&self,
base: &[u8],
exp: &[u8],
modulus: &[u8],
) -> Result<Vec<u8>, crate::provider::CryptoError> {
match crate::modexp_montgomery::modexp(base, exp, modulus) {
Some(result) => Ok(result),
None => crate::provider::modexp_arbitrary_precision(base, exp, modulus),
}
}
}