heuristics

package
v0.0.0-...-bcfd2cf Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MajorityLikelihood = map[byte]float64{
	byte(0b10011101): 100.00,
	byte(0b10011100): 100.00,
	byte(0b10011):    96.06,
	byte(0b10111):    93.85,
	byte(0b10010000): 99.99,
	byte(0b10001101): 100.00,
	byte(0b10001):    94.18,
	byte(0b11000):    100.00,
	byte(0b10001001): 100.00,
	byte(0b10010001): 100.00,
	byte(0b10010010): 100.00,
	byte(0b10110):    91.87,
	byte(0b100):      61.50,
	byte(0b1):        58.32,
	byte(0b1001):     83.78,
	byte(0b10011001): 100.00,
	byte(0b1000):     90.33,
	byte(0b10010101): 100.00,
	byte(0b10001000): 99.92,
	byte(0b11):       96.09,
	byte(0b0):        87.23,
	byte(0b10000):    96.57,
	byte(0b10000110): 100.00,
	byte(0b10001100): 99.93,
	byte(0b101):      80.60,
	byte(0b10000001): 100.00,
	byte(0b1101):     80.50,
	byte(0b10010100): 100.00,
	byte(0b1100):     79.09,
	byte(0b10000000): 95.66,
	byte(0b10000010): 100.00,
	byte(0b10000100): 99.76,
	byte(0b10):       96.05,
	byte(0b10000101): 100.00,
	byte(0b10010110): 100.00,
	byte(0b11100):    100.00,
	byte(0b111):      72.94,
	byte(0b11001):    100.00,
	byte(0b10011000): 100.00,
	byte(0b10000111): 100.00,
	byte(0b110):      59.63,
	byte(0b10010111): 100.00,
	byte(0b10100):    78.78,
	byte(0b10000011): 100.00,
	byte(0b11101):    100.00,
	byte(0b10101):    66.49,
	byte(0b10010):    99.02,
	byte(0b10010011): 100.00,
}

MajorityLikelihood mapp to define majority voting probability

Functions

func ApplyChangeConditionSet

func ApplyChangeConditionSet(db kv.DB, transaction tx.Tx, vuln *Map)

ApplyChangeConditionSet applies the set of passed heuristics to the passed transaction

func ApplyChangeSet

func ApplyChangeSet(db kv.DB, c *cache.Cache, transaction tx.Tx, heuristicsList Mask, vuln *Map)

ApplyChangeSet applies the set of passed heuristics to the passed transaction

func ApplyConditionSet

func ApplyConditionSet(db kv.DB, transaction tx.Tx, vuln *Mask)

ApplyConditionSet applies the set of passed heuristics to the passed transaction

func ApplyFullSet

func ApplyFullSet(db kv.DB, c *cache.Cache, transaction tx.Tx, vuln *Mask)

ApplyFullSet applies the set of heuristics to the passed transaction

func ApplySet

func ApplySet(db kv.DB, c *cache.Cache, transaction tx.Tx, heuristicsList Mask, vuln *Mask)

ApplySet applies the set of passed heuristics to the passed transaction

Types

type Condition

type Condition func(*tx.Tx) bool

Condition function signature for condition definition

type ConditionsSet

type ConditionsSet []Condition

ConditionsSet defines the list of transacions applicable conditions

type Heuristic

type Heuristic int

Heuristic type define a enum on implemented heuristics

const (
	Locktime Heuristic = iota
	Peeling
	PowerOfTen
	OptimalChange
	AddressType
	AddressReuse
	Shadow
	ClientBehaviour

	ExactAmount
	Backward
	Forward

	Coinbase
	SelfTransfer
	OffByOne
	PeelingLike
)

func Abbreviation

func Abbreviation(a string) Heuristic

Abbreviation returns vulnerable function to be applied to analysis

func Index

func Index(h string) Heuristic

Index returns the index corresponding the heuristic

func List

func List() (heuristics []Heuristic)

List returns the list of heuristics

func SetCardinality

func SetCardinality() Heuristic

SetCardinality returns the cardinality of the heuristics set

func (Heuristic) Apply

func (h Heuristic) Apply(db kv.DB, c *cache.Cache, transaction tx.Tx, vuln *Mask)

Apply applies the heuristic specified to the passed transaction

func (Heuristic) ApplyChange

func (h Heuristic) ApplyChange(db kv.DB, ca *cache.Cache, transaction tx.Tx, vuln *Map)

ApplyChange applies the heuristic specified to the passed transaction

func (Heuristic) ApplyChangeCondition

func (h Heuristic) ApplyChangeCondition(db kv.DB, transaction tx.Tx, vuln *Map)

ApplyChangeCondition applies the heuristic specified to the passed transaction

func (Heuristic) ApplyCondition

func (h Heuristic) ApplyCondition(db kv.DB, transaction tx.Tx, vuln *Mask)

ApplyCondition applies the heuristic specified to the passed transaction

func (Heuristic) ConditionFunction

func (h Heuristic) ConditionFunction() func(*tx.Tx) bool

ConditionFunction returns change output function to be applied to analysis

func (Heuristic) Implementation

func (h Heuristic) Implementation(db kv.DB, ca *cache.Cache) HeuristicImpl

Implementation returns concrete implementation for the heuristic

func (Heuristic) String

func (h Heuristic) String() string

type HeuristicImpl

type HeuristicImpl interface {
	ChangeOutput(transaction *tx.Tx) (c []uint32, err error)
	Vulnerable(transaction *tx.Tx) bool
}

HeuristicImpl generic heuristic methods interface

type Map

type Map map[Heuristic]uint32

Map analysis output map for heuristics change output

func MapFromHeuristics

func MapFromHeuristics(args ...Heuristic) (m Map)

MapFromHeuristics intialized a null map with passed heuristics as keys

func MergeMaps

func MergeMaps(a, b Map) (new Map)

MergeMaps maps returns the merge of two maps

func (Map) IsCoinbase

func (v Map) IsCoinbase() bool

IsCoinbase checks if corresponding condition bit is true

func (Map) IsOffByOneBug

func (v Map) IsOffByOneBug() bool

IsOffByOneBug checks if corresponding condition bit is true

func (Map) IsPeelingLike

func (v Map) IsPeelingLike() bool

IsPeelingLike checks if corresponding condition bit is true

func (Map) IsSelfTransfer

func (v Map) IsSelfTransfer() bool

IsSelfTransfer checks if corresponding condition bit is true

func (Map) MajorityOutput

func (v Map) MajorityOutput(reducing ...Heuristic) (r Map, output uint32)

MajorityOutput extract the majority output set from map

func (Map) ToHeuristicsList

func (v Map) ToHeuristicsList() (heuristics []string)

ToHeuristicsList return a list of heuristic names corresponding to vulnerability byte passed

func (Map) ToList

func (v Map) ToList() (heuristics []Heuristic)

ToList return a list of heuristic integers corresponding to vulnerability byte passed

func (Map) ToMask

func (v Map) ToMask() (m Mask)

ToMask converts the Map to a Mask ignoring values

type Mask

type Mask [3]byte

Mask struct to represent heuristics vulnerability mask

func FromListToMask

func FromListToMask(list []Heuristic) (m Mask)

FromListToMask convert list of heuristics to mask type

func MaskFromPower

func MaskFromPower(h Heuristic) (m Mask)

MaskFromPower returns the mask byte from the power of 2

func MergeMasks

func MergeMasks(source Mask, update Mask) Mask

MergeMasks uses bitwise OR operation to apply a mask to vulnerabilities byte to merge a new mask with updated heuristics bit and return the merge between original byte with updated bits

func (Mask) IsCoinbase

func (v Mask) IsCoinbase() bool

IsCoinbase checks if corresponding condition bit is true

func (Mask) IsOffByOneBug

func (v Mask) IsOffByOneBug() bool

IsOffByOneBug checks if corresponding condition bit is true

func (Mask) IsPeelingLike

func (v Mask) IsPeelingLike() bool

IsPeelingLike checks if corresponding condition bit is true

func (Mask) IsSelfTransfer

func (v Mask) IsSelfTransfer() bool

IsSelfTransfer checks if corresponding condition bit is true

func (*Mask) Sum

func (v *Mask) Sum(m Mask) Mask

Sum returns the updated base mask

func (Mask) ToHeuristicsList

func (v Mask) ToHeuristicsList() (heuristics []string)

ToHeuristicsList return a list of heuristic names corresponding to vulnerability byte passed

func (Mask) ToList

func (v Mask) ToList() (heuristics []Heuristic)

ToList return a list of heuristic integers corresponding to vulnerability byte passed

func (Mask) VulnerableMask

func (v Mask) VulnerableMask(h Heuristic) (vuln bool)

VulnerableMask uses bitwise AND operation to apply a mask to vulnerabilities byte to extract value bit by bit and returns true if the vuln byte is vulnerable to passed heuristic

Directories

Path Synopsis
Package backward heuristic It checks the transactions that come before the one in which we want to find the change address.
Package backward heuristic It checks the transactions that come before the one in which we want to find the change address.
Package behaviour client heuristic This heuristic checks if there are output addresses that are the first time they appear in the Blockchain.
Package behaviour client heuristic This heuristic checks if there are output addresses that are the first time they appear in the Blockchain.
Package forward heuristic It checks the transactions that come after the one in which we want to find the change address.
Package forward heuristic It checks the transactions that come after the one in which we want to find the change address.
Package locktime heuristic It checks for each output of a transaction, if the spending transactions locktime is the same of the original transaction.
Package locktime heuristic It checks for each output of a transaction, if the spending transactions locktime is the same of the original transaction.
Package optimal change heuristic It tries to locate in the output set of a transaction an address that receives an amount which is smaller or equal than all inputs values.
Package optimal change heuristic It tries to locate in the output set of a transaction an address that receives an amount which is smaller or equal than all inputs values.
Package peeling chain heuristic Since in this case we are looking for a set of transactions that have different length, can be really difficult to be sure that a series of transactions that have one input and two outputs is a peeling chains transaction, also because a chain can be connected in the middle point of another chain.
Package peeling chain heuristic Since in this case we are looking for a set of transactions that have different length, can be really difficult to be sure that a series of transactions that have one input and two outputs is a peeling chains transaction, also because a chain can be connected in the middle point of another chain.
Package power of ten heuristic It checks if in the outputs set there are addresses that have an amount in Satoshi that is a power of ten.
Package power of ten heuristic It checks if in the outputs set there are addresses that have an amount in Satoshi that is a power of ten.
Package reuse heuristic This heuristic just checks if an address that appears in the input set, appears also in the output set, we just need to count the number of transactions in which this condition is satisfied.
Package reuse heuristic This heuristic just checks if an address that appears in the input set, appears also in the output set, we just need to count the number of transactions in which this condition is satisfied.
Package shadow heuristic This heuristic checks if there are output addresses that are the first time they appear in the Blockchain.
Package shadow heuristic This heuristic checks if there are output addresses that are the first time they appear in the Blockchain.
Package class heuristic This heuristic is the address type heuristic and it checks if the all the inputs are of the same type and then try to locate only one output that is of the same type.
Package class heuristic This heuristic is the address type heuristic and it checks if the all the inputs are of the same type and then try to locate only one output that is of the same type.

Jump to

Keyboard shortcuts

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