crypto

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PUSH1 = 0x51

	// encoded public key length 0x21 || encoded public key (33 bytes) || OP_CHECKSIG(0xac)
	PublicKeyScriptLength = 35

	// signature length(0x40) || 64 bytes signature
	SignatureScriptLength = 65

	// 1byte m || 3 encoded public keys with leading 0x40 (34 bytes * 3) ||
	// 1byte n + 1byte OP_CHECKMULTISIG
	MinMultiSignCodeLength = 71
)
View Source
const (
	SignerLength      = 32
	SignatureLength   = 64
	NegativeBigLength = 33
)
View Source
const (
	INFINITYLEN      = 1
	FLAGLEN          = 1
	XORYVALUELEN     = 32
	COMPRESSEDLEN    = 33
	NOCOMPRESSEDLEN  = 65
	COMPEVENFLAG     = 0x02
	COMPODDFLAG      = 0x03
	NOCOMPRESSEDFLAG = 0x04
	P256PARAMA       = -3
)

Variables

This section is empty.

Functions

func AesDecrypt added in v0.2.2

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

func AesEncrypt added in v0.2.2

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

func AppendSignature added in v0.2.2

func AppendSignature(signerIndex int, signature, data, code, param []byte) ([]byte, error)

func ComputeParent added in v0.2.2

func ComputeParent(left common.Uint256, right common.Uint256) common.Uint256

func ComputeRoot

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

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

func Equal added in v0.2.2

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

func GetM added in v0.2.2

func GetM(code []byte) (uint, error)

func GetScriptType added in v0.2.2

func GetScriptType(script []byte) (byte, error)

func GetSignStatus added in v0.2.2

func GetSignStatus(code, param []byte) (haveSign, needSign int, err error)

func ParseCrossChainScript added in v0.2.2

func ParseCrossChainScript(code []byte) ([][]byte, error)

func ParseMultisigScript added in v0.2.2

func ParseMultisigScript(code []byte) ([][]byte, error)

func Sign added in v0.2.2

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

func SortPublicKeys added in v0.2.2

func SortPublicKeys(publicKeys []*PublicKey)

func ToAesKey added in v0.2.2

func ToAesKey(pwd []byte) []byte

func Verify

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

Types

type CryptoAlgSet

type CryptoAlgSet struct {
	EccParams elliptic.CurveParams
	Curve     elliptic.Curve
}

type MerkleTree

type MerkleTree struct {
	Depth uint
	Root  *MerkleTreeNode
}

func NewMerkleTree

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

use []Uint256 to create a new MerkleTree

type MerkleTreeNode

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

func (*MerkleTreeNode) IsLeaf

func (t *MerkleTreeNode) IsLeaf() bool

type PublicKey added in v0.2.2

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

func DecodePoint

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

func GenerateKeyPair added in v0.2.2

func GenerateKeyPair() ([]byte, *PublicKey, error)

func GenerateSubKeyPair added in v0.2.2

func GenerateSubKeyPair(index int, chainCode, parentPrivateKey []byte) ([]byte, *PublicKey, error)

func NewPubKey added in v0.2.2

func NewPubKey(priKey []byte) *PublicKey

func (*PublicKey) Deserialize added in v0.2.2

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

func (*PublicKey) EncodePoint added in v0.2.2

func (e *PublicKey) EncodePoint(isCompressed bool) ([]byte, error)

func (*PublicKey) Serialize added in v0.2.2

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

Jump to

Keyboard shortcuts

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