parseSignature
Parses a hex formatted signature into a structured Signature
Loading...
Parses a hex formatted signature into a structured Signature
Parses a hex formatted signature into a structured Signature with R, S, V, and YParity components.
import "github.com/ChefBingbong/viem-go/utils/signature"import "github.com/ChefBingbong/viem-go/utils/signature"
sig, err := signature.ParseSignature( "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c",)if err != nil { log.Fatal(err)}
fmt.Printf("R: %s", sig.R)// R: 0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf
fmt.Printf("S: %s", sig.S)// S: 0x4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db8
fmt.Printf("YParity: %d", sig.YParity)// YParity: 1
fmt.Printf("V: %s", sig.V.String())// V: 28(*signature.Signature, error)A structured signature with R, S, V, and YParity fields.
stringThe hex formatted signature string. Must be 65 bytes (130 hex characters with 0x prefix).
sig, _ := signature.ParseSignature( "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c",)The parsed signature contains:
Parses a hex signature string:
sig, _ := signature.ParseSignature("0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c")
Parses a 65-byte signature:
sig, _ := signature.ParseSignatureBytes([]byte{0x6e, 0x10, ...})
The signature format is: