Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

LibLeafProof

Git Source

Functions

proveIflagsY

Prove the value of the iflags_Y register of a machine.

May raise InvalidSiblingsArrayLength or InvalidMachineMerkleProof.

function proveIflagsY(LeafProof calldata v, bytes32 machineMerkleRoot)
    internal
    pure
    returns (uint64 iflagsY);

Parameters

NameTypeDescription
vLeafProofThe leaf proof for the iflags_Y register
machineMerkleRootbytes32The machine Merkle root

Returns

NameTypeDescription
iflagsYuint64The iflags_Y register

proveHtifTohost

Prove the value of the HTIF tohost register of a machine.

May raise InvalidSiblingsArrayLength or InvalidMachineMerkleProof.

function proveHtifTohost(LeafProof calldata v, bytes32 machineMerkleRoot)
    internal
    pure
    returns (uint64 htifTohost);

Parameters

NameTypeDescription
vLeafProofThe leaf proof for the HTIF tohost register
machineMerkleRootbytes32The machine Merkle root

Returns

NameTypeDescription
htifTohostuint64The HTIF tohost register

proveTxBuffer

Prove the first data block of the CMIO tx buffer of a machine.

May raise InvalidSiblingsArrayLength or InvalidMachineMerkleProof.

function proveTxBuffer(LeafProof calldata v, bytes32 machineMerkleRoot)
    internal
    pure
    returns (bytes32 txBuffer);

Parameters

NameTypeDescription
vLeafProofThe leaf proof for the first data block of the CMIO tx buffer
machineMerkleRootbytes32The machine Merkle root

Returns

NameTypeDescription
txBufferbytes32The first data block of the CMIO tx buffer

proveWord

Prove a word at a given address in the machine.

May raise InvalidSiblingsArrayLength or InvalidMachineMerkleProof.

function proveWord(
    LeafProof calldata v,
    bytes32 machineMerkleRoot,
    uint64 wordAddress
) internal pure returns (uint64 word);

Parameters

NameTypeDescription
vLeafProofThe leaf proof
machineMerkleRootbytes32The machine Merkle root
wordAddressuint64The word address

Returns

NameTypeDescription
worduint64The proven word

proveDataBlock

Prove the value of a data block at a given address in the machine.

May raise InvalidSiblingsArrayLength or InvalidMachineMerkleProof.

function proveDataBlock(
    LeafProof calldata v,
    bytes32 machineMerkleRoot,
    uint64 dataBlockAddress
) internal pure returns (bytes32 dataBlock);

Parameters

NameTypeDescription
vLeafProofThe leaf proof
machineMerkleRootbytes32The machine Merkle root
dataBlockAddressuint64The data block address

Returns

NameTypeDescription
dataBlockbytes32The proven data block

proveDataBlock

Prove the value of a data block at a given leaf index in the machine.

May raise InvalidSiblingsArrayLength or InvalidMachineMerkleProof.

function proveDataBlock(
    LeafProof calldata v,
    bytes32 machineMerkleRoot,
    LeafIndex leafIndex
) internal pure returns (bytes32 dataBlock);

Parameters

NameTypeDescription
vLeafProofThe leaf proof
machineMerkleRootbytes32The machine Merkle root
leafIndexLeafIndexThe leaf index

Returns

NameTypeDescription
dataBlockbytes32The proven data block

computeMachineMerkleRoot

Compute the machine Merkle root from a leaf proof.

May raise InvalidSiblingsArrayLength.

function computeMachineMerkleRoot(LeafProof calldata v, LeafIndex leafIndex)
    internal
    pure
    returns (bytes32 machineMerkleRoot);

Parameters

NameTypeDescription
vLeafProofThe leaf proof
leafIndexLeafIndexThe leaf index

Returns

NameTypeDescription
machineMerkleRootbytes32The computed machine Merkle root

truncateToLeaf

Truncate a word address into leaf index and word offset.

function truncateToLeaf(uint64 wordAddress)
    internal
    pure
    returns (LeafIndex leafIndex, WordOffset wordOffset);

Parameters

NameTypeDescription
wordAddressuint64The word address

Returns

NameTypeDescription
leafIndexLeafIndexThe leaf index
wordOffsetWordOffsetThe word offset within the data block

getUint64WordFromDataBlock

Get uint64 word at offset from data block.

Converts word from little-endian to big-endian order.

function getUint64WordFromDataBlock(bytes32 dataBlock, WordOffset wordOffset)
    internal
    pure
    returns (uint64 word);

Parameters

NameTypeDescription
dataBlockbytes32The data block
wordOffsetWordOffsetThe word offset within the data block

Returns

NameTypeDescription
worduint64The uint64 word