crypto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCHEME_ECDSA              = "ecdsa"
	PUBLICKEY_FINGERPRINT_LEN = 8
)

Variables

View Source
var CryptoSchemes = map[string]Factory{}
View Source
var DefaultRandSrc io.Reader
View Source
var DefaultVersion int32

Functions

func DecodeCompactSignature

func DecodeCompactSignature(sig string) (*protos.Signature, error)

we define a compact, simple encoding for the protbuf signature before our SDK for other language is mature... which has such a form: <crypto scheme mark>:<encoded sig>:[derived part := <index>,<finger print>,[cc]]

func EncodeCompactSignature

func EncodeCompactSignature(sig *protos.Signature) (string, error)

func PrivateKeySign

func PrivateKeySign(s Signer, index *big.Int, hash []byte) (*protos.Signature, error)

func PrivatekeyToString

func PrivatekeyToString(priv Signer) (string, error)

func PublicKeyToBytes

func PublicKeyToBytes(pk Verifier) ([]byte, error)

Types

type Factory

type Factory interface {
	NewSigner() Signer
	NewVerifier() Verifier
}

type Hierarchical

type Hierarchical interface {
	GetRootFingerPrint() []byte
	GetIndex() *big.Int
	Child(*big.Int) (Hierarchical, error)
}

type Signer

type Signer interface {
	Hierarchical
	Public() Verifier
	Sign([]byte) (*protos.Signature, error)
	// contains filtered or unexported methods
}

func GetChildPrivateKey

func GetChildPrivateKey(s Signer, index *big.Int) (Signer, error)

func PrivateKeyFromPBMessage

func PrivateKeyFromPBMessage(privProto *protos.PrivateKey) (Signer, error)

func PrivatekeyFromBytes

func PrivatekeyFromBytes(raw []byte) (Signer, error)

func PrivatekeyFromString

func PrivatekeyFromString(privkeyStr string) (Signer, error)

type Verifier

type Verifier interface {
	Hierarchical
	Verify([]byte, *protos.Signature) bool
	//the Verifier recovered from signature is not hierarchical
	Recover(*protos.Signature) error
	Digest() []byte
	// contains filtered or unexported methods
}

func DecodeCompactPublicKey

func DecodeCompactPublicKey(pk string) (Verifier, error)

func GetChildPublicKey

func GetChildPublicKey(pk Verifier, index *big.Int) (Verifier, error)

func PublicKeyFromBytes

func PublicKeyFromBytes(raw []byte) (Verifier, error)

func PublicKeyFromPBMessage

func PublicKeyFromPBMessage(pubProto *protos.PublicKey) (Verifier, error)

func PublicKeyFromSignature

func PublicKeyFromSignature(sig *protos.Signature) (Verifier, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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