crypto

package
v0.0.0-...-950a2ea Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KyberSuite = edwards25519.NewBlakeSHA256Ed25519()

	PointG = KyberSuite.Point().Base()

	PointH = KyberSuite.Point().Base().Mul(hScalar, nil)
)

Functions

func Decrypt

func Decrypt(privateKey kyber.Scalar, cipherText *CipherText) (int64, error)

func DecryptPoint

func DecryptPoint(privateKey kyber.Scalar, cipherTextBytes []byte) (kyber.Point, error)

func GenerateMerkleProofs

func GenerateMerkleProofs(dataBlocks []mt.DataBlock) ([]*mt.Proof, []byte, error)

func KeyGen

func KeyGen() (privateKey TypePrivateKey, publicKey TypePublicKey, err error)

func MerkleBatchProofMarshal

func MerkleBatchProofMarshal(proof *MerkleBatchProof) ([]byte, error)

func MerkleProofMarshal

func MerkleProofMarshal(proof *mt.Proof) ([]byte, error)

func MerkleProofUnmarshal

func MerkleProofUnmarshal(data []byte) (*mt.Proof, error)

func PedersenCommit

func PedersenCommit(amount int64) (kyber.Point, kyber.Scalar, error)

func PedersonCommitWithHash

func PedersonCommitWithHash(amount, timestamp int64,
	receiverHash []byte, counter uint64) (kyber.Point, kyber.Point, error)

func RandBytes

func RandBytes() ([]byte, error)

func RandScalars

func RandScalars(size int) []kyber.Scalar

func VerifyMerkleBatchProof

func VerifyMerkleBatchProof(dataBlocks []mt.DataBlock, batchProof *MerkleBatchProof, root []byte) (bool, error)

VerifyMerkleBatchProof verifies the batched proof against the given root hash.

func VerifyMerkleProof

func VerifyMerkleProof(block mt.DataBlock, proof *mt.Proof, root []byte) (bool, error)

Types

type CipherText

type CipherText struct {
	C1 kyber.Point
	C2 kyber.Point
}

func DeserializeCipherText

func DeserializeCipherText(data []byte) (*CipherText, error)

func Encrypt

func Encrypt(publicKey kyber.Point, amount int64) (*CipherText, error)

func EncryptPoint

func EncryptPoint(publicKey, data kyber.Point) (*CipherText, error)

func (*CipherText) Serialize

func (c *CipherText) Serialize() ([]byte, error)

type KeyPair

type KeyPair struct {
	PrivateKey TypePrivateKey
	PublicKey  TypePublicKey
}

type MerkleBatchProof

type MerkleBatchProof struct {
	Nodes   []ProofNode `json:"nodes"`
	Indexes []int       `json:"indexes"`
}

MerkleBatchProof is the batched proof for a set of data blocks.

func MerkleBatchProofUnmarshal

func MerkleBatchProofUnmarshal(data []byte) (*MerkleBatchProof, error)

func NewMerkleBatchProof

func NewMerkleBatchProof(dataBlocks []mt.DataBlock, proofs []*mt.Proof) (*MerkleBatchProof, error)

NewMerkleBatchProof creates a batched proof for the given data blocks and their individual proofs.

type MerkleProof

type MerkleProof struct {
	Siblings [][]byte `json:"siblings"`
	Path     uint32   `json:"path"`
}

type ProofNode

type ProofNode struct {
	Coordinate [2]int
	Data       []byte
}

type TypePrivateKey

type TypePrivateKey kyber.Scalar

type TypePublicKey

type TypePublicKey kyber.Point

Jump to

Keyboard shortcuts

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