zcash

package
v0.0.0-...-1c9500d Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxBlockBaseSize = 2000000

	NumJoinSplitInputs  = 2
	NumJoinSplitOutputs = 2

	SproutVersionGroupID uint32 = 0

	OverwinterFlagMask       uint32 = 0x80000000
	OverwinterVersionGroupID        = 0x03C48270

	TxExpiryHeightThreshold uint32 = 500000000

	SproutMinCurrentVersion     uint32 = 1
	SproutMaxCurrentVersion            = 2
	OverwinterMinCurrentVersion        = 3
	OverwinterMaxCurrentVersion        = 3
)

Variables

View Source
var (
	ErrOverwinterTxVersionTooLow = fmt.Errorf("overwinter transaction version too low")
	ErrUnknownTxVersionGroupID   = fmt.Errorf("transaction has unknown version group id")
	ErrTxExpiryHeightIsTooHigh   = fmt.Errorf("transaction expiry height is too high")
	ErrTxVersionTooLow           = fmt.Errorf("transaction version too low")
	ErrTxVersionTooHigh          = fmt.Errorf("transaction version too high")
	ErrNoTxInputs                = fmt.Errorf("transaction has no inputs")
	ErrNoTxOutputs               = fmt.Errorf("transaction has no outputs")
	ErrDuplicateTxInputs         = fmt.Errorf("transaction contains duplicate inputs")
	ErrDuplicateTxNullifiers     = fmt.Errorf("transaction contains duplicate nullifiers")
	ErrPrevOutIsNull             = fmt.Errorf("transaction input refers to null previous output")
	ErrCoinBaseTxHasJoinSplits   = fmt.Errorf("coinbase transaction has joinsplits")
	ErrCoinBaseTxHasOutputs      = fmt.Errorf("coinbase transaction has outputs")
)

Functions

func MoneyRange

func MoneyRange(v int64) bool

Types

type Input

type Input struct {
	PreviousOutPoint wire.OutPoint
	SignatureScript  []byte
	Sequence         uint32
}

func (Input) IsEqual

func (i Input) IsEqual(other Input) bool

func (*Input) ReadFrom

func (i *Input) ReadFrom(r io.Reader) (int64, error)

func (*Input) WriteTo

func (i *Input) WriteTo(w io.Writer) (int64, error)

type JoinSplit

type JoinSplit struct {
	// A value v_{pub}^{old} that the JoinSplit transfer removes from the
	// transparent value pool.
	VPubOld uint64

	// A value v_{pub}^{new} that the JoinSplit transfer inserts into the
	// transparent value pool.
	VPubNew uint64

	// A merkle root of the note commitment tree at some block height in the
	// past, or the merkle root produced by a previous JoinSplit transfer in this
	// transaction.
	//
	// JoinSplits are always anchored to a root in the note commitment tree at
	// some point in the blockchain history or in the history of the current
	// transaction.
	Anchor [32]byte

	// A sequence of nullifiers of the input notes $nf$_{1..N^{old}}^{old}
	//
	// Nullifiers are used to prevent double-spends. They are derived from the
	// secrets placed in the note and the secret spend-authority key known by the
	// spender.
	Nullifiers [NumJoinSplitInputs][32]byte

	// A sequence of note commitments for the output notes $cm$_{1..N^{new}}^{new}
	//
	// Note commitments are introduced into the commitment tree, blinding the
	// public about the values and destinations involved in the JoinSplit. The
	// presence of a commitment in the note commitment tree is required to spend
	// it.
	Commitments [NumJoinSplitOutputs][32]byte

	// A Curve25519 public key epk.
	EphemeralKey [32]byte

	// A 256-bit seed that must be chosen independently at random for each
	// JoinSplit description.
	RandomSeed [32]byte

	// A sequence of message authentication tags h_{1..N^{old}} that bind h^{Sig}
	// to each a_{sk} of the JoinSplit description.
	//
	// The verification of the JoinSplit requires these MACs to be provided as an
	// input.
	Macs [NumJoinSplitInputs][32]byte

	// An encoding of the zero-knowledge proof \pi_{ZKJoinSplit}
	//
	// This is a zk-SNARK which ensures that this JoinSplit is valid.
	Proof [296]byte

	// A sequence of ciphertext components for the encrypted output notes,
	// C_{1..N^{new}}^{enc}
	//
	// These contain trapdoors, values and other information that the recipient
	// needs, including a memo field. It is encrypted using the scheme
	// implemented in crypto/NoteEncryption.cpp
	Ciphertexts [NumJoinSplitOutputs][601]byte
}

func (JoinSplit) IsEqual

func (js JoinSplit) IsEqual(other JoinSplit) bool

func (*JoinSplit) ReadFrom

func (js *JoinSplit) ReadFrom(r io.Reader) (int64, error)

func (*JoinSplit) WriteTo

func (js *JoinSplit) WriteTo(w io.Writer) (n int64, err error)

type Output

type Output struct {
	Value        int64
	ScriptPubKey []byte
}

func (Output) IsEqual

func (o Output) IsEqual(other Output) bool

func (*Output) ReadFrom

func (o *Output) ReadFrom(r io.Reader) (int64, error)

func (*Output) SerializeSize

func (o *Output) SerializeSize() int

SerializeSize returns the number of bytes it would take to serialize the the transaction output.

func (*Output) WriteTo

func (o *Output) WriteTo(w io.Writer) (int64, error)

type Transaction

type Transaction struct {
	IsOverwinter       bool
	Version            uint32
	VersionGroupID     uint32
	Inputs             []Input
	Outputs            []Output
	LockTime           uint32
	ExpiryHeight       uint32
	JoinSplits         []JoinSplit
	JoinSplitPubKey    [32]byte
	JoinSplitSignature [64]byte
}

func (*Transaction) GetHeader

func (t *Transaction) GetHeader() uint32

func (*Transaction) IsCoinBase

func (t *Transaction) IsCoinBase() bool

IsCoinBase determines whether or not a transaction is a coinbase. A coinbase is a special transaction created by miners that has no inputs. This is represented in the block chain by a transaction with a single input that has a previous output transaction index set to the maximum value along with a zero hash.

func (*Transaction) IsEqual

func (t *Transaction) IsEqual(other *Transaction) bool

func (*Transaction) MarshalBinary

func (t *Transaction) MarshalBinary() ([]byte, error)

func (*Transaction) ReadFrom

func (t *Transaction) ReadFrom(r io.Reader) (n int64, err error)

func (*Transaction) TxHash

func (t *Transaction) TxHash() chainhash.Hash

TxHash generates the Hash for the transaction.

func (*Transaction) UnmarshalBinary

func (t *Transaction) UnmarshalBinary(data []byte) error

func (*Transaction) Validate

func (tx *Transaction) Validate(params *chaincfg.Params) error

func (*Transaction) WriteTo

func (t *Transaction) WriteTo(w io.Writer) (n int64, err error)

Jump to

Keyboard shortcuts

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