crypto

package
v1.1.7-beta Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: Apache-2.0 Imports: 8 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

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)
	}
)
View Source
var Sha256ZeroHash = make([]byte, 32)

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 CheckPrivateKey

func CheckPrivateKey(privateKey []byte) error

func CheckPublicKey

func CheckPublicKey(publicKey []byte) error

func CheckSeed

func CheckSeed(seed []byte) error

func ComputeRoot

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

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

func GenKeyPair

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

func GenerateVrf

func GenerateVrf(privateKey, data []byte, randSrc bool) ([]byte, []byte, error)

func GetPrivateKeyFromSeed

func GetPrivateKeyFromSeed(seed []byte) []byte

func GetPublicKeyFromPrivateKey

func GetPublicKeyFromPrivateKey(privateKey []byte) []byte

func GetSeedFromPrivateKey

func GetSeedFromPrivateKey(priKey []byte) []byte

func PKCS5Padding

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

func PKCS5UnPadding

func PKCS5UnPadding(src []byte) []byte

func Sign

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

func ToAesKey

func ToAesKey(pwd []byte) []byte

func Verify

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

func VerifyVrf

func VerifyVrf(publicKey, data, vrf, proof []byte) bool

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

Directories

Path Synopsis
edwards25519
Package edwards25519 implements operations in GF(2**255-19) and on an Edwards curve that is isomorphic to curve25519.
Package edwards25519 implements operations in GF(2**255-19) and on an Edwards curve that is isomorphic to curve25519.
vrf
Package ed25519 implements a verifiable random function using the Edwards form of Curve25519, SHA512 and the Elligator map.
Package ed25519 implements a verifiable random function using the Edwards form of Curve25519, SHA512 and the Elligator map.

Jump to

Keyboard shortcuts

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