Struct DefaultCrypto

Source
pub struct DefaultCrypto;
Expand description

Default implementation of the Crypto trait using the existing crypto libraries.

Trait Implementations§

Source§

impl Clone for DefaultCrypto

Source§

fn clone(&self) -> DefaultCrypto

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Crypto for DefaultCrypto

Source§

fn sha256(&self, input: &[u8]) -> [u8; 32]

Compute SHA-256 hash
Source§

fn ripemd160(&self, input: &[u8]) -> [u8; 32]

Compute RIPEMD-160 hash
Source§

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>

BN254 elliptic curve scalar multiplication.
Source§

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>

secp256k1 ECDSA signature recovery.
Source§

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, )

Blake2 compression function.
Source§

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>

KZG point evaluation.
Source§

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>

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>

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>

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>

BLS12-381 pairing check.
Source§

fn bls12_381_fp_to_g1(&self, fp: &[u8; 48]) -> Result<[u8; 96], PrecompileError>

BLS12-381 map field element to G1.
Source§

fn bls12_381_fp2_to_g2( &self, fp2: ([u8; 48], [u8; 48]), ) -> Result<[u8; 192], PrecompileError>

BLS12-381 map field element to G2.
Source§

impl Debug for DefaultCrypto

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V