pub struct DefaultCrypto;
Expand description
Default implementation of the Crypto trait using the existing crypto libraries.
Trait Implementations§
Source§impl Clone for DefaultCrypto
impl Clone for DefaultCrypto
Source§fn clone(&self) -> DefaultCrypto
fn clone(&self) -> DefaultCrypto
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Crypto for DefaultCrypto
impl Crypto for DefaultCrypto
Source§fn bn254_g1_add(
&self,
p1: &[u8],
p2: &[u8],
) -> Result<[u8; 64], PrecompileError>
fn bn254_g1_add( &self, p1: &[u8], p2: &[u8], ) -> Result<[u8; 64], PrecompileError>
BN254 elliptic curve addition.
Source§fn bn254_g1_mul(
&self,
point: &[u8],
scalar: &[u8],
) -> Result<[u8; 64], PrecompileError>
fn bn254_g1_mul( &self, point: &[u8], scalar: &[u8], ) -> Result<[u8; 64], PrecompileError>
BN254 elliptic curve scalar multiplication.
Source§fn bn254_pairing_check(
&self,
pairs: &[(&[u8], &[u8])],
) -> Result<bool, PrecompileError>
fn bn254_pairing_check( &self, pairs: &[(&[u8], &[u8])], ) -> Result<bool, PrecompileError>
BN254 pairing check.
Source§fn secp256k1_ecrecover(
&self,
sig: &[u8; 64],
recid: u8,
msg: &[u8; 32],
) -> Result<[u8; 32], PrecompileError>
fn secp256k1_ecrecover( &self, sig: &[u8; 64], recid: u8, msg: &[u8; 32], ) -> Result<[u8; 32], PrecompileError>
secp256k1 ECDSA signature recovery.
Source§fn modexp(
&self,
base: &[u8],
exp: &[u8],
modulus: &[u8],
) -> Result<Vec<u8>, PrecompileError>
fn modexp( &self, base: &[u8], exp: &[u8], modulus: &[u8], ) -> Result<Vec<u8>, PrecompileError>
Modular exponentiation.
Source§fn blake2_compress(
&self,
rounds: u32,
h: &mut [u64; 8],
m: [u64; 16],
t: [u64; 2],
f: bool,
)
fn blake2_compress( &self, rounds: u32, h: &mut [u64; 8], m: [u64; 16], t: [u64; 2], f: bool, )
Blake2 compression function.
Source§fn secp256r1_verify_signature(
&self,
msg: &[u8; 32],
sig: &[u8; 64],
pk: &[u8; 64],
) -> bool
fn secp256r1_verify_signature( &self, msg: &[u8; 32], sig: &[u8; 64], pk: &[u8; 64], ) -> bool
secp256r1 (P-256) signature verification.
Source§fn verify_kzg_proof(
&self,
z: &[u8; 32],
y: &[u8; 32],
commitment: &[u8; 48],
proof: &[u8; 48],
) -> Result<(), PrecompileError>
fn verify_kzg_proof( &self, z: &[u8; 32], y: &[u8; 32], commitment: &[u8; 48], proof: &[u8; 48], ) -> Result<(), PrecompileError>
KZG point evaluation.
Source§fn bls12_381_g1_add(
&self,
a: G1Point,
b: G1Point,
) -> Result<[u8; 96], PrecompileError>
fn bls12_381_g1_add( &self, a: G1Point, b: G1Point, ) -> Result<[u8; 96], PrecompileError>
BLS12-381 G1 addition (returns 96-byte unpadded G1 point)
Source§fn bls12_381_g1_msm(
&self,
pairs: &mut dyn Iterator<Item = Result<G1PointScalar, PrecompileError>>,
) -> Result<[u8; 96], PrecompileError>
fn bls12_381_g1_msm( &self, pairs: &mut dyn Iterator<Item = Result<G1PointScalar, PrecompileError>>, ) -> Result<[u8; 96], PrecompileError>
BLS12-381 G1 multi-scalar multiplication (returns 96-byte unpadded G1 point)
Source§fn bls12_381_g2_add(
&self,
a: G2Point,
b: G2Point,
) -> Result<[u8; 192], PrecompileError>
fn bls12_381_g2_add( &self, a: G2Point, b: G2Point, ) -> Result<[u8; 192], PrecompileError>
BLS12-381 G2 addition (returns 192-byte unpadded G2 point)
Source§fn bls12_381_g2_msm(
&self,
pairs: &mut dyn Iterator<Item = Result<G2PointScalar, PrecompileError>>,
) -> Result<[u8; 192], PrecompileError>
fn bls12_381_g2_msm( &self, pairs: &mut dyn Iterator<Item = Result<G2PointScalar, PrecompileError>>, ) -> Result<[u8; 192], PrecompileError>
BLS12-381 G2 multi-scalar multiplication (returns 192-byte unpadded G2 point)
Source§fn bls12_381_pairing_check(
&self,
pairs: &[(G1Point, G2Point)],
) -> Result<bool, PrecompileError>
fn bls12_381_pairing_check( &self, pairs: &[(G1Point, G2Point)], ) -> Result<bool, PrecompileError>
BLS12-381 pairing check.
Source§fn bls12_381_fp_to_g1(&self, fp: &[u8; 48]) -> Result<[u8; 96], PrecompileError>
fn bls12_381_fp_to_g1(&self, fp: &[u8; 48]) -> Result<[u8; 96], PrecompileError>
BLS12-381 map field element to G1.
Auto Trait Implementations§
impl Freeze for DefaultCrypto
impl RefUnwindSafe for DefaultCrypto
impl Send for DefaultCrypto
impl Sync for DefaultCrypto
impl Unpin for DefaultCrypto
impl UnwindSafe for DefaultCrypto
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more