Documentation ¶
Index ¶
- Constants
- func CompressPubKey(pubKey *ecdsa.PublicKey) []byte
- func DecompressPubKey(pubKey []byte) (*ecdsa.PublicKey, error)
- func EcRecover(hash, sig []byte) ([]byte, error)
- func Keccak256(data ...[]byte) []byte
- func Keccak256Hash(data ...[]byte) (h [32]byte)
- func Keccak512(data ...[]byte) []byte
- func S256() elliptic.Curve
- func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)
- func Sign(hash []byte, prv *ecdsa.PrivateKey) ([]byte, error)
- func ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool
- func VerifySignature(pubKey, hash, signature []byte) bool
Constants ¶
const DigestLength = 32
DigestLength sets the signature digest exact length
const RecoveryIDOffset = 64
RecoveryIDOffset points to the byte offset within the signature that contains the recovery id.
const SignatureLength = 64 + 1 // 64 bytes ECDSA signature + 1 byte recovery id
SignatureLength indicates the byte length required to carry a signature with recovery id.
Variables ¶
This section is empty.
Functions ¶
func CompressPubKey ¶
CompressPubKey encodes a public key to the 33-byte compressed format.
func DecompressPubKey ¶
DecompressPubkey parses a public key in the 33-byte compressed format.
func Keccak256Hash ¶
Keccak256Hash calculates and returns the Keccak256 hash of the input data, converting it to an internal Hash data structure.
func Sign ¶
func Sign(hash []byte, prv *ecdsa.PrivateKey) ([]byte, error)
Sign calculates an ECDSA signature.
This function is susceptible to chosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given hash cannot be chosen by an adversery. Common solution is to hash any input before calculating the signature.
The produced signature is in the [R || S || V] format where V is 0 or 1.
func ValidateSignatureValues ¶
ValidateSignatureValues verifies whether the signature values are valid with the given chain rules. The v value is assumed to be either 0 or 1.
func VerifySignature ¶
VerifySignature checks that the given public key created signature over hash. The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format. The signature should have the 64 byte [R || S] format.
Types ¶
This section is empty.