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

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

@toshihiko-okubo

Description

@toshihiko-okubo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions