algorithm

package
v0.0.0-...-fc775d1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeliosAlgorithm

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

HeliosAlgorithm implements the three-stage Helios proof of work algorithm

func NewHeliosAlgorithm

func NewHeliosAlgorithm(config *HeliosConfig) *HeliosAlgorithm

NewHeliosAlgorithm creates a new Helios algorithm instance

func (*HeliosAlgorithm) Mine

func (h *HeliosAlgorithm) Mine(blockHeader []byte, targetDifficulty *big.Int) (*HeliosProof, error)

Mine attempts to find a valid proof of work using the Helios algorithm

func (*HeliosAlgorithm) ValidateProof

func (h *HeliosAlgorithm) ValidateProof(proof *HeliosProof, blockHeader []byte, targetDifficulty *big.Int) error

ValidateProof validates a Helios proof

type HeliosConfig

type HeliosConfig struct {
	// Stage weights (must sum to 100)
	MemoryWeight   int `json:"memory_weight"`   // 40%
	TimeLockWeight int `json:"timelock_weight"` // 30%
	CryptoWeight   int `json:"crypto_weight"`   // 30%

	// Memory phase parameters
	MemoryBaseSize    int     `json:"memory_base_size"`    // 64MB
	MemoryScaleFactor float64 `json:"memory_scale_factor"` // 1.0
	MemoryIterations  int     `json:"memory_iterations"`   // 3

	// Time-lock parameters
	TimeLockBaseDuration time.Duration `json:"timelock_base_duration"` // 50ms
	TimeLockScaleFactor  float64       `json:"timelock_scale_factor"`  // 1.0
	TimeLockIterations   int           `json:"timelock_iterations"`    // 1000

	// Cryptographic parameters
	CryptoKeySize    int `json:"crypto_key_size"`   // 32 bytes
	CryptoBlockSize  int `json:"crypto_block_size"` // 16 bytes
	CryptoIterations int `json:"crypto_iterations"` // 10000

	// Energy tracking
	EnableEnergyTracking bool `json:"enable_energy_tracking"` // false initially
}

HeliosConfig holds configuration for the Helios algorithm

func DefaultHeliosConfig

func DefaultHeliosConfig() *HeliosConfig

DefaultHeliosConfig returns the default configuration for Helios Optimized for 20-second block time

func TestHeliosConfig

func TestHeliosConfig() *HeliosConfig

TestHeliosConfig returns a configuration for fast mining in tests

type HeliosProof

type HeliosProof struct {
	Nonce        uint64    `json:"nonce"`
	Timestamp    time.Time `json:"timestamp"`
	Stage1Result []byte    `json:"stage1_result"` // Memory phase result
	Stage2Result []byte    `json:"stage2_result"` // Time-lock phase result
	Stage3Result []byte    `json:"stage3_result"` // Cryptographic phase result
	FinalHash    string    `json:"final_hash"`
	Difficulty   *big.Int  `json:"difficulty"`
	EnergyUsed   int64     `json:"energy_used"` // CPU cycles used
}

HeliosProof represents a complete proof of work for the Helios algorithm

Jump to

Keyboard shortcuts

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