pub struct CryptoWrapper<A>where
A: CryptoApi,{ /* private fields */ }
Implementations§
Source§impl<A> CryptoWrapper<A>where
A: CryptoApi,
impl<A> CryptoWrapper<A>where
A: CryptoApi,
pub fn new() -> Self
pub fn sha256<B: Borrow<ManagedBuffer<A>>>( &self, data: B, ) -> ManagedByteArray<A, SHA256_RESULT_LEN>
pub fn keccak256<B: Borrow<ManagedBuffer<A>>>( &self, data: B, ) -> ManagedByteArray<A, KECCAK256_RESULT_LEN>
pub fn ripemd160<B: Borrow<ManagedBuffer<A>>>( &self, data: B, ) -> ManagedByteArray<A, { crate::api::RIPEMD_RESULT_LEN }>
pub fn verify_bls( &self, key: &ManagedBuffer<A>, message: &ManagedBuffer<A>, signature: &ManagedBuffer<A>, )
Sourcepub fn verify_ed25519(
&self,
key: &ManagedBuffer<A>,
message: &ManagedBuffer<A>,
signature: &ManagedBuffer<A>,
)
pub fn verify_ed25519( &self, key: &ManagedBuffer<A>, message: &ManagedBuffer<A>, signature: &ManagedBuffer<A>, )
Calls the Vm to verify ed25519 signature.
Does not return result, will fail tx directly!
The error comes straight form the VM, the message is “invalid signature”.
Sourcepub fn verify_secp256k1(
&self,
key: &ManagedBuffer<A>,
message: &ManagedBuffer<A>,
signature: &ManagedBuffer<A>,
) -> bool
pub fn verify_secp256k1( &self, key: &ManagedBuffer<A>, message: &ManagedBuffer<A>, signature: &ManagedBuffer<A>, ) -> bool
Note: the signature is minimum 2 bytes in length, the second byte encodes the length of the remaining signature bytes.
pub fn verify_custom_secp256k1( &self, key: &ManagedBuffer<A>, message: &ManagedBuffer<A>, signature: &ManagedBuffer<A>, hash_type: MessageHashType, ) -> bool
pub fn encode_secp256k1_der_signature( &self, r: &ManagedBuffer<A>, s: &ManagedBuffer<A>, ) -> ManagedBuffer<A>
Sourcepub fn verify_secp256r1(
&self,
key: &ManagedBuffer<A>,
message: &ManagedBuffer<A>,
signature: &ManagedBuffer<A>,
)
pub fn verify_secp256r1( &self, key: &ManagedBuffer<A>, message: &ManagedBuffer<A>, signature: &ManagedBuffer<A>, )
Calls the Vm to verify secp256r1 signature.
Does not return result, will fail tx directly!
Calls the Vm to verify BLS signature share.
Does not return result, will fail tx directly!
Sourcepub fn verify_bls_aggregated_signature(
&self,
keys: &ManagedVec<A, ManagedBuffer<A>>,
message: &ManagedBuffer<A>,
signature: &ManagedBuffer<A>,
)
pub fn verify_bls_aggregated_signature( &self, keys: &ManagedVec<A, ManagedBuffer<A>>, message: &ManagedBuffer<A>, signature: &ManagedBuffer<A>, )
Calls the Vm to verify BLS aggregated signature.
Does not return result, will fail tx directly!
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for CryptoWrapper<A>
impl<A> RefUnwindSafe for CryptoWrapper<A>where
A: RefUnwindSafe,
impl<A> Send for CryptoWrapper<A>where
A: Send,
impl<A> Sync for CryptoWrapper<A>where
A: Sync,
impl<A> Unpin for CryptoWrapper<A>where
A: Unpin,
impl<A> UnwindSafe for CryptoWrapper<A>where
A: UnwindSafe,
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