Documentation
¶
Index ¶
- Constants
- Variables
- func AesCTRXOR(key, inText, iv []byte) ([]byte, error)
- func AesDecrypt(crypted, key []byte) ([]byte, error)
- func AesEncrypt(origData, key []byte) ([]byte, error)
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func Keccak256(data ...[]byte) []byte
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func Ripemd160(data []byte) []byte
- func S256() elliptic.Curve
- func ZeroKey(k *PrivateKey)
- type Hash
- func (h Hash) Bytes() []byte
- func (h Hash) Equal(h1 Hash) bool
- func (h Hash) MarshalText() ([]byte, error)
- func (h Hash) PrefixLen() int
- func (h *Hash) Reverse() Hash
- func (h *Hash) SetBytes(b []byte)
- func (h *Hash) SetString(s string)
- func (h Hash) String() string
- func (h *Hash) UnmarshalText(input []byte) error
- func (h Hash) Xor(h1 Hash) Hash
- type PrivateKey
- type PublicKey
- type Signature
- func (sig *Signature) Bytes() []byte
- func (sig *Signature) Ecrecover(hash []byte) ([]byte, error)
- func (sig Signature) MarshalText() ([]byte, error)
- func (sig *Signature) RecoverPublicKey(hash []byte) (*PublicKey, error)
- func (sig *Signature) SetBytes(data []byte, compressed bool)
- func (sig *Signature) UnmarshalText(input []byte) error
- func (sig *Signature) VRS() (v byte, r, s *big.Int)
- func (sig *Signature) Validate() bool
- func (sig *Signature) Verify(hash []byte, pub *PublicKey) bool
Constants ¶
const (
// HashSize represents the hash length
HashSize = 32
)
const (
// SignatureSize represents the signature length
SignatureSize = 65
)
Variables ¶
var ( // N is secp256k1 N N = S256().Params().N )
Functions ¶
func AesDecrypt ¶
AesDecrypt decrypts data using the specified key
func AesEncrypt ¶
AesEncrypt encrypts data using the specified key
func PKCS5Padding ¶
PKCS5Padding padding data
Types ¶
type Hash ¶
Hash represents the 32 byte hash of arbitrary data
func ComputeMerkleHash ¶
ComputeMerkleHash returns the merkle root hash of the hash lists
func DoubleSha256 ¶
DoubleSha256 calculates and returns double sha256 hash of the input data
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type PrivateKey ¶
type PrivateKey ecdsa.PrivateKey
PrivateKey represents the ecdsa privatekey
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*PrivateKey, error)
HexToECDSA parses a secp256k1 private key
func LoadECDSA ¶
func LoadECDSA(file string) (*PrivateKey, error)
LoadECDSA loads a private key from the given file
func ToECDSA ¶
func ToECDSA(prv []byte) *PrivateKey
ToECDSA creates a private key with the given D value.
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() *PublicKey
Public returns the public key corresponding to priv.
func (*PrivateKey) SaveECDSA ¶
func (priv *PrivateKey) SaveECDSA(file string) error
SaveECDSA saves a private key to the given file
func (*PrivateKey) SecretBytes ¶
func (priv *PrivateKey) SecretBytes() []byte
SecretBytes returns the actual bytes of ecdsa privatekey
type PublicKey ¶
PublicKey represents the ecdsa publickey
func ToECDSAPub ¶
ToECDSAPub returns ecdsa public key according the input data
type Signature ¶
type Signature [SignatureSize]byte
Signature represents the ecdsa_signcompact signature data format [r - s - v]
func (Signature) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Signature) RecoverPublicKey ¶
RecoverPublicKey recovers public key and also verifys the signature
func (*Signature) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.