crypto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DOUBLE_SHA256 = func(s []common.Uint256) common.Uint256 {
		b := new(bytes.Buffer)
		for _, d := range s {
			d.Serialize(b)
		}
		temp := sha256.Sum256(b.Bytes())
		f := sha256.Sum256(temp[:])
		return common.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 []common.Uint256) (common.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 PasswordHash

func PasswordHash(password []byte) []byte

func Sign

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

func Verify

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

func VerifyRoot

func VerifyRoot(txnsHash []common.Uint256, txnsRoot []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 []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

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