Add PoolL2Tx verify signature needed methods

Implements the hash to be signed from PoolL2Tx, compatible with javascript version.
Implements the signature verification for a given PoolL2Tx.
This commit is contained in:
arnaucube
2020-08-24 09:41:43 +02:00
parent 869ab519a4
commit 7fa658cc84
4 changed files with 86 additions and 2 deletions

View File

@@ -1,5 +1,11 @@
package common
import (
"math/big"
ethCommon "github.com/ethereum/go-ethereum/common"
)
// SwapEndianness swaps the order of the bytes in the slice.
func SwapEndianness(b []byte) []byte {
o := make([]byte, len(b))
@@ -8,3 +14,8 @@ func SwapEndianness(b []byte) []byte {
}
return o
}
// EthAddrToBigInt returns a *big.Int from a given ethereum common.Address.
func EthAddrToBigInt(a ethCommon.Address) *big.Int {
return new(big.Int).SetBytes(a.Bytes())
}