Contains functions for ed25519 digital signatures.
- Function
ed25519_validate_pubkey
- Function
ed25519_verify
- Function
native_ecrecover
- Function
ecrecover
- Function
secp256k1_verify
- Module Specification
use 0x1::EVMAddress;
use 0x1::Option;
use 0x1::Vector;
public fun ed25519_validate_pubkey(public_key: vector<u8>): bool
Implementation
native public fun ed25519_validate_pubkey(public_key: vector<u8>): bool;
public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool
Implementation
native public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool;
recover address from ECDSA signature, if recover fail, return an empty vector
fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>
Implementation
native fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>;
recover address from ECDSA signature, if recover fail, return None
public fun ecrecover(hash: vector<u8>, signature: vector<u8>): Option::Option<EVMAddress::EVMAddress>
Implementation
public fun ecrecover(hash: vector<u8>, signature: vector<u8>):Option<EVMAddress>{
let bytes = native_ecrecover(hash, signature);
if (Vector::is_empty(&bytes)){
Option::none<EVMAddress>()
}else{
Option::some(EVMAddress::new(bytes))
}
}
public fun secp256k1_verify(signature: vector<u8>, addr: vector<u8>, message: vector<u8>): bool
Implementation
public fun secp256k1_verify(signature: vector<u8>, addr: vector<u8>, message: vector<u8>) : bool{
let receover_address_opt:Option<EVMAddress> = ecrecover(message, signature);
let expect_address = EVMAddress::new(addr);
&Option::destroy_some<EVMAddress>(receover_address_opt) == &expect_address
}
pragma intrinsic = true;