consensushashing

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockHash

func BlockHash(block *external.DomainBlock) *external.DomainHash

BlockHash returns the given block's hash

func CalculateSignatureHashECDSA

func CalculateSignatureHashECDSA(tx *external.DomainTransaction, inputIndex int, hashType SigHashType,
	reusedValues *SighashReusedValues) (*external.DomainHash, error)

CalculateSignatureHashECDSA will, given a script and hash type calculate the signature hash to be used for signing and verification for ECDSA. This returns error only if one of the provided parameters are consensus-invalid.

func CalculateSignatureHashSchnorr

func CalculateSignatureHashSchnorr(tx *external.DomainTransaction, inputIndex int, hashType SigHashType,
	reusedValues *SighashReusedValues) (*external.DomainHash, error)

CalculateSignatureHashSchnorr will, given a script and hash type calculate the signature hash to be used for signing and verification for Schnorr. This returns error only if one of the provided parameters are consensus-invalid.

func HeaderHash

func HeaderHash(header external.BaseBlockHeader) *external.DomainHash

HeaderHash returns the given header's hash

func TransactionHash

func TransactionHash(tx *external.DomainTransaction) *external.DomainHash

TransactionHash returns the transaction hash.

func TransactionID

TransactionID generates the Hash for the transaction without the signature script and payload field.

func TransactionIDs

func TransactionIDs(txs []*external.DomainTransaction) []*external.DomainTransactionID

TransactionIDs converts the provided slice of DomainTransactions to a corresponding slice of TransactionIDs

Types

type SigHashType

type SigHashType uint8

SigHashType represents hash type bits at the end of a signature.

const (
	SigHashAll          SigHashType = 0b00000001
	SigHashNone         SigHashType = 0b00000010
	SigHashSingle       SigHashType = 0b00000100
	SigHashAnyOneCanPay SigHashType = 0b10000000

	// SigHashMask defines the number of bits of the hash type which is used
	// to identify which outputs are signed.
	SigHashMask = 0b00000111
)

Hash type bits from the end of a signature.

func (SigHashType) IsStandardSigHashType

func (sht SigHashType) IsStandardSigHashType() bool

IsStandardSigHashType returns true if sht represents a standard SigHashType

type SighashReusedValues

type SighashReusedValues struct {
	// contains filtered or unexported fields
}

SighashReusedValues holds all fields used in the calculation of a transaction's sigHash, that are the same for all transaction inputs. Reuse of such values prevents the quadratic hashing problem.

Jump to

Keyboard shortcuts

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