Documentation ¶
Overview ¶
Copyright (C) 2017, Zipper Team. All rights reserved.
This file is part of zipper ¶
The zipper is free software: you can use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
The zipper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ISC License for more details.
You should have received a copy of the ISC License along with this program. If not, see <https://opensource.org/licenses/isc>.
Copyright (C) 2017, Zipper Team. All rights reserved.
This file is part of zipper ¶
The zipper is free software: you can use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
The zipper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ISC License for more details.
You should have received a copy of the ISC License along with this program. If not, see <https://opensource.org/licenses/isc>.
Copyright (C) 2017, Zipper Team. All rights reserved.
This file is part of zipper ¶
The zipper is free software: you can use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
The zipper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ISC License for more details.
You should have received a copy of the ISC License along with this program. If not, see <https://opensource.org/licenses/isc>.
Copyright (C) 2017, Zipper Team. All rights reserved.
This file is part of zipper ¶
The zipper is free software: you can use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
The zipper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ISC License for more details.
You should have received a copy of the ISC License along with this program. If not, see <https://opensource.org/licenses/isc>.
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 GeneratePrivateKeyBytes(privateKey *rsa.PrivateKey) ([]byte, error)
- func GenerateRootCertificateBytes(rootCertificate *x509.Certificate, rootPrivateKey *rsa.PrivateKey) ([]byte, error)
- func Keccak256(data ...[]byte) []byte
- func LoadCrypter(file string, name string) (crypter.IPrivateKey, error)
- func NewCertificate(info CertInformation) *x509.Certificate
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func Parse(cert, key []byte) (rootCertificate *x509.Certificate, rootPrivateKey *rsa.PrivateKey, err error)
- func ParseCrt(data []byte) (*x509.Certificate, error)
- func ParseKey(data []byte) (*rsa.PrivateKey, error)
- func Ripemd160(data []byte) []byte
- func S256() elliptic.Curve
- func SaveCrypter(file string, name string, priv crypter.IPrivateKey) error
- func SignRsa(privateKey *rsa.PrivateKey, data []byte) ([]byte, error)
- func VerifyCertificate(rootCertificate, Certificate *x509.Certificate) error
- func VerifySign(hashed [sha256.Size]byte, sign []byte, Certificate *x509.Certificate) error
- func ZeroKey(k *PrivateKey)
- type CertInformation
- 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 GeneratePrivateKeyBytes ¶
func GeneratePrivateKeyBytes(privateKey *rsa.PrivateKey) ([]byte, error)
func GenerateRootCertificateBytes ¶
func GenerateRootCertificateBytes(rootCertificate *x509.Certificate, rootPrivateKey *rsa.PrivateKey) ([]byte, error)
func LoadCrypter ¶
func LoadCrypter(file string, name string) (crypter.IPrivateKey, error)
func NewCertificate ¶
func NewCertificate(info CertInformation) *x509.Certificate
func PKCS5Padding ¶
PKCS5Padding padding data
func Parse ¶
func Parse(cert, key []byte) (rootCertificate *x509.Certificate, rootPrivateKey *rsa.PrivateKey, err error)
func SaveCrypter ¶
func SaveCrypter(file string, name string, priv crypter.IPrivateKey) error
func VerifyCertificate ¶
func VerifyCertificate(rootCertificate, Certificate *x509.Certificate) error
VerifyCertificate use root Certificate to verify remote Certificate
func VerifySign ¶
Types ¶
type CertInformation ¶
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.