0x1::Signature
Contains functions for ed25519 digital signatures.
ed25519_validate_pubkey
ed25519_verify
native_ecrecover
ecrecover
secp256k1_verify
use 0x1::EVMAddress;
use 0x1::Option;
use 0x1::Vector;
ed25519_validate_pubkey
public fun ed25519_validate_pubkey(public_key: vector<u8>): bool
native public fun ed25519_validate_pubkey(public_key: vector<u8>): bool;
ed25519_verify
public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool
native public fun ed25519_verify(signature: vector<u8>, public_key: vector<u8>, message: vector<u8>): bool;
native_ecrecover
recover address from ECDSA signature, if recover fail, return an empty vector
fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>
native fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>;
ecrecover
recover address from ECDSA signature, if recover fail, return None
public fun ecrecover(hash: vector<u8>, signature: vector<u8>): Option::Option<EVMAddress::EVMAddress>
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))
}
}
secp256k1_verify
public fun secp256k1_verify(signature: vector<u8>, addr: vector<u8>, message: vector<u8>): bool
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;