Add ecrecover syscall (backport #17720) (#18500)

* Add ecrecover syscall (#17720)

Co-authored-by: Anton Lisanin <lisanin.anton@gmail.com>
(cherry picked from commit 1f288ce527)

# Conflicts:
#	Cargo.lock
#	programs/bpf/Cargo.lock
#	programs/bpf/tests/programs.rs
#	programs/bpf_loader/Cargo.toml
#	programs/bpf_loader/src/syscalls.rs
#	sdk/program/Cargo.toml

* resolve conflicts

Co-authored-by: s-medvedev <40623263+s-medvedev@users.noreply.github.com>
Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2021-07-08 21:56:19 +00:00
committed by GitHub
parent 030a97d098
commit 8c328316ae
16 changed files with 504 additions and 8 deletions

View File

@@ -457,6 +457,37 @@ uint64_t sol_keccak256(
uint8_t *result
);
/** Length of a secp256k1 recover input hash */
#define SECP256K1_RECOVER_HASH_LENGTH 32
/** Length of a secp256k1 input signature */
#define SECP256K1_RECOVER_SIGNATURE_LENGTH 64
/** Length of a secp256k1 recover result */
#define SECP256K1_RECOVER_RESULT_LENGTH 64
/** The hash provided to a sol_secp256k1_recover is invalid */
#define SECP256K1_RECOVER_ERROR_INVALID_HASH 1
/** The recovery_id provided to a sol_secp256k1_recover is invalid */
#define SECP256K1_RECOVER_ERROR_INVALID_RECOVERY_ID 2
/** The signature provided to a sol_secp256k1_recover is invalid */
#define SECP256K1_RECOVER_ERROR_INVALID_SIGNATURE 3
/**
* Recover public key from a signed message.
*
* @param hash Hashed message
* @param recovery_id Tag used for public key recovery from signatures. Can be 0 or 1
* @param signature An ECDSA signature
* @param result 64 byte array to hold the result. A recovered public key
* @return 0 if executed successfully
*/
uint64_t sol_secp256k1_recover(
const uint8_t *hash,
uint64_t recovery_id,
const uint8_t *signature,
uint8_t *result
);
/**
* Account Meta
*/