starcoin-framework

Module 0x1::Signature

Contains functions for ed25519 digital signatures.

use 0x1::EVMAddress;
use 0x1::Option;
use 0x1::Vector;

Function ed25519_validate_pubkey

public fun ed25519_validate_pubkey(public_key: vector<u8>): bool
Implementation
native public fun ed25519_validate_pubkey(public_key: vector<u8>): bool;

Function ed25519_verify

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;

Function 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>
Implementation
native fun native_ecrecover(hash: vector<u8>, signature: vector<u8>): vector<u8>;

Function ecrecover

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

Module Specification

pragma intrinsic = true;