Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

[EVM] An error occurs when ecrecover is called. #1530

Open
2 tasks done
toshihiko-okubo opened this issue Feb 22, 2022 · 0 comments
Open
2 tasks done

[EVM] An error occurs when ecrecover is called. #1530

toshihiko-okubo opened this issue Feb 22, 2022 · 0 comments

Comments

@toshihiko-okubo
Copy link

toshihiko-okubo commented Feb 22, 2022

Describe the Bug
The signature to be passed to btcec.RecoverCompact must have the structure [v, r, s], but the current implementation of ecrecover has the structure [r, s, v], which always causes an error.
https://github.com/btcsuite/btcec/blob/BTCEC_0_2_2/signature.go#L386-L391

To Reproduce
Implement and call the function to call ecrecover in smartContract.

Expected Behavior
https://github.com/hyperledger/burrow/blob/v0.34.4/execution/native/precompiles.go#L75-L82

v := ctx.Input[binary.Word256Bytes : 2*binary.Word256Bytes]
if !binary.IsZeros(v[:len(v)-1]) {
	return nil, fmt.Errorf("ecrecover: recovery ID is larger than one byte")
}
// Copy in v to first element of sig
sig[0] = v[len(v)-1]

// Copy in r, s
copy(sig[1:], ctx.Input[2*binary.Word256Bytes:4*binary.Word256Bytes])

Technical Details

  • Burrow Version (docker image tag or branch if built from source)
    • v0.34.4
  • Go Version (if applicable)
    • 1.16.9
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant