PHP Class ParagonIE\Halite\Structure\MerkleTree

Show file Open project: paragonie/halite

Protected Properties

Property Type Description
$nodes Node[]
$outputSize integer
$personalization string
$root string
$rootCalculated boolean

Public Methods

Method Description
__construct ( variadic $nodes ) Instantiate a Merkle tree
getExpandedTree ( variadic $nodes ) : MerkleTree Merkle Trees are immutable. Return a replacement with extra nodes.
getRoot ( boolean $raw = false ) : string Get the root hash of this Merkle tree.
getSizeRoundedUp ( integer $inputSize ) : integer Let's go ahead and round up to the nearest multiple of 2
setHashSize ( integer $size ) : self Set the hash output size.
setPersonalizationString ( string $str = '' ) : self Sets the personalization string for the Merkle root calculation
triggerRootCalculation ( ) : self Explicitly recalculate the Merkle root

Protected Methods

Method Description
calculateRoot ( ) : string Calculate the Merkle root, taking care to distinguish between leaves and branches (0x01 for the nodes, 0x00 for the branches) to protect against second-preimage attacks

Method Details

__construct() public method

Instantiate a Merkle tree
public __construct ( variadic $nodes )
$nodes variadic

calculateRoot() protected method

Calculate the Merkle root, taking care to distinguish between leaves and branches (0x01 for the nodes, 0x00 for the branches) to protect against second-preimage attacks
protected calculateRoot ( ) : string
return string

getExpandedTree() public method

Merkle Trees are immutable. Return a replacement with extra nodes.
public getExpandedTree ( variadic $nodes ) : MerkleTree
$nodes variadic
return MerkleTree

getRoot() public method

Get the root hash of this Merkle tree.
public getRoot ( boolean $raw = false ) : string
$raw boolean - Do we want a raw string instead of a hex string?
return string

getSizeRoundedUp() public static method

Let's go ahead and round up to the nearest multiple of 2
public static getSizeRoundedUp ( integer $inputSize ) : integer
$inputSize integer
return integer

setHashSize() public method

Set the hash output size.
public setHashSize ( integer $size ) : self
$size integer
return self

setPersonalizationString() public method

Sets the personalization string for the Merkle root calculation
public setPersonalizationString ( string $str = '' ) : self
$str string
return self

triggerRootCalculation() public method

Explicitly recalculate the Merkle root
public triggerRootCalculation ( ) : self
return self

Property Details

$nodes protected property

protected Node[],ParagonIE\Halite\Structure $nodes
return Node[]

$outputSize protected property

protected int $outputSize
return integer

$personalization protected property

protected string $personalization
return string

$root protected property

protected string $root
return string

$rootCalculated protected property

protected bool $rootCalculated
return boolean