crypto

package
v0.0.0-...-2fecb0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package crypto is a generated protocol buffer package.

It is generated from these files:

crazybits/x/crypto/crypto.proto

It has these top-level messages:

PublicKey
PrivateKey
Signature

Index

Constants

This section is empty.

Variables

View Source
var CryptoType_name = map[int32]string{
	0: "ECDSA",
	1: "RSA",
	2: "DSA",
}
View Source
var CryptoType_value = map[string]int32{
	"ECDSA": 0,
	"RSA":   1,
	"DSA":   2,
}

Functions

func CompressedPublicKeyToHexString

func CompressedPublicKeyToHexString(pub *secp256k1.PublicKey) string

CompressedPublicKeyToHexString convert secp256k1 compressed public key to hex string

func Decode

func Decode(b string) []byte

Decode decodes a modified base58 string to a byte slice.

func Decrypt

func Decrypt(password string, cipherText []byte) []byte

Decrypt aes cbc decryption

func Encode

func Encode(b []byte) string

Encode encodes a byte slice to a modified base58 string.

func Encrypt

func Encrypt(password string, plainText []byte) []byte

Encrypt aes cbc encrption

func HexToPrivateKey

func HexToPrivateKey(hexkey string) *secp256k1.PrivateKey

HexToPrivateKey convert hex private key to secp256k1 private key

func PrivateKeyToHexString

func PrivateKeyToHexString(priv *secp256k1.PrivateKey) string

PrivateKeyToHexString convert secp256k1 private key to hex string

func PublicKeyToHexString

func PublicKeyToHexString(pub *secp256k1.PublicKey) string

PublicKeyToHexString convert secp256k1 uncompressed public key to hex string

func StrToPrivateKey

func StrToPrivateKey(str string) *secp256k1.PrivateKey

StrToPrivateKey generate private key from given string

func ToECDSA

func ToECDSA(prv []byte) *ecdsa.PrivateKey

ToECDSA convert bytes to ecdsa private key

Types

type CryptoType

type CryptoType int32
const (
	CryptoType_ECDSA CryptoType = 0
	CryptoType_RSA   CryptoType = 1
	CryptoType_DSA   CryptoType = 2
)

func (CryptoType) EnumDescriptor

func (CryptoType) EnumDescriptor() ([]byte, []int)

func (CryptoType) String

func (x CryptoType) String() string

type PrivateKey

type PrivateKey struct {
	Type CryptoType `protobuf:"varint,1,opt,name=type,enum=crypto.CryptoType" json:"type,omitempty"`
	Key  []byte     `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
}

func GenePrivateKeyFromSeed

func GenePrivateKeyFromSeed(hash []byte) *PrivateKey

GenePrivateKeyFromSeed generate private key from seed

func NewPrivateKey

func NewPrivateKey() *PrivateKey

NewPrivateKey create private key

func (*PrivateKey) Descriptor

func (*PrivateKey) Descriptor() ([]byte, []int)

func (*PrivateKey) GenerateSharedSecret

func (privateKey *PrivateKey) GenerateSharedSecret(publicKey *PublicKey) []byte

GenerateSharedSecret generate shared secret between self private key and target public key

func (*PrivateKey) ProtoMessage

func (*PrivateKey) ProtoMessage()

func (*PrivateKey) PublicKey

func (privateKey *PrivateKey) PublicKey() *PublicKey

PublicKey get the compressed public key

func (*PrivateKey) Reset

func (m *PrivateKey) Reset()

func (*PrivateKey) Sign

func (privateKey *PrivateKey) Sign(hash []byte) *Signature

Sign sign the provided data

func (*PrivateKey) String

func (m *PrivateKey) String() string

type PublicKey

type PublicKey struct {
	Type CryptoType `protobuf:"varint,1,opt,name=type,enum=crypto.CryptoType" json:"type,omitempty"`
	Key  []byte     `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"`
}

func (*PublicKey) Descriptor

func (*PublicKey) Descriptor() ([]byte, []int)

func (*PublicKey) ProtoMessage

func (*PublicKey) ProtoMessage()

func (*PublicKey) Reset

func (m *PublicKey) Reset()

func (*PublicKey) String

func (m *PublicKey) String() string

func (*PublicKey) VerifySign

func (publicKey *PublicKey) VerifySign(hash []byte, signature *Signature) bool

type Signature

type Signature struct {
	Type CryptoType `protobuf:"varint,1,opt,name=type,enum=crypto.CryptoType" json:"type,omitempty"`
	R    []byte     `protobuf:"bytes,2,opt,name=r,proto3" json:"r,omitempty"`
	S    []byte     `protobuf:"bytes,3,opt,name=s,proto3" json:"s,omitempty"`
}

func (*Signature) Descriptor

func (*Signature) Descriptor() ([]byte, []int)

func (*Signature) ProtoMessage

func (*Signature) ProtoMessage()

func (*Signature) Reset

func (m *Signature) Reset()

func (*Signature) String

func (m *Signature) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL