crypto

package
v0.3.14-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2018 License: Apache-2.0 Imports: 16 Imported by: 39

Documentation

Index

Constants

View Source
const (
	INFINITYLEN      = 1
	FLAGLEN          = 1
	XORYVALUELEN     = 32
	COMPRESSEDLEN    = 33
	NOCOMPRESSEDLEN  = 65
	COMPEVENFLAG     = 0x02
	COMPODDFLAG      = 0x03
	NOCOMPRESSEDFLAG = 0x04
	P256PARAMA       = -3
)
View Source
const (
	P256R1 = 0
)

Variables

View Source
var AlgChoice int

It can be P256R1

View Source
var (
	DOUBLE_SHA256 = func(s []Uint256) Uint256 {
		b := new(bytes.Buffer)
		for _, d := range s {
			d.Serialize(b)
		}
		temp := sha256.Sum256(b.Bytes())
		f := sha256.Sum256(temp[:])
		return Uint256(f)
	}
)

Functions

func AesDecrypt

func AesDecrypt(ciphertext []byte, key []byte, iv []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(plaintext []byte, key []byte, iv []byte) ([]byte, error)

func ComputeRoot

func ComputeRoot(hashes []Uint256) (Uint256, error)

input a []uint256, create a MerkleTree & calc the root hash

func Equal

func Equal(e1 *PubKey, e2 *PubKey) bool

func PKCS5Padding

func PKCS5Padding(src []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(src []byte) []byte

func SetAlg

func SetAlg(algChoice string)

func Sha256

func Sha256(value []byte) []byte

func Sign

func Sign(privateKey []byte, data []byte) ([]byte, error)

func ToAesKey

func ToAesKey(pwd []byte) []byte

func Verify

func Verify(publicKey PubKey, data []byte, signature []byte) error

Types

type MerkleTree

type MerkleTree struct {
	Depth uint
	Root  *MerkleTreeNode
}

func NewMerkleTree

func NewMerkleTree(hashes []Uint256) (*MerkleTree, error)

use []Uint256 to create a new MerkleTree

type MerkleTreeNode

type MerkleTreeNode struct {
	Hash  Uint256
	Left  *MerkleTreeNode
	Right *MerkleTreeNode
}

func (*MerkleTreeNode) IsLeaf

func (t *MerkleTreeNode) IsLeaf() bool

type PubKey

type PubKey struct {
	X, Y *big.Int
}

func DecodePoint

func DecodePoint(encodeData []byte) (*PubKey, error)

func GenKeyPair

func GenKeyPair() ([]byte, PubKey, error)

func NewPubKey

func NewPubKey(priKey []byte) *PubKey

func (*PubKey) Deserialize

func (e *PubKey) Deserialize(r io.Reader) error

func (*PubKey) EncodePoint

func (e *PubKey) EncodePoint(isCommpressed bool) ([]byte, error)

func (*PubKey) Serialize

func (e *PubKey) Serialize(w io.Writer) error

type PubKeySlice

type PubKeySlice []*PubKey

func (PubKeySlice) Len

func (p PubKeySlice) Len() int

func (PubKeySlice) Less

func (p PubKeySlice) Less(i, j int) bool

func (PubKeySlice) Swap

func (p PubKeySlice) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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