Manifest Root Registry

manifest-root-registry · discovery-registry · 988 B runtime · registry-info

scores

source

pragma solidity ^0.8.13;

contract ManifestRootRegistry {
    event RootSet(address indexed agent, bytes32 root);

    mapping(address => bytes32) private _roots;

    function setRoot(bytes32 root) external {
        _roots[msg.sender] = root;
        emit RootSet(msg.sender, root);
    }

    function getRoot(address agent) external view returns (bytes32) {
        return _roots[agent];
    }

    function verify(address agent, bytes32 leaf, bytes32[] calldata proof) external view returns (bool) {
        bytes32 root = _roots[agent];
        bytes32 computed = leaf;

        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 sibling = proof[i];
            if (computed < sibling) {
                computed = keccak256(abi.encodePacked(computed, sibling));
            } else {
                computed = keccak256(abi.encodePacked(sibling, computed));
            }
        }

        return computed == root;
    }

    function makeLeaf(bytes calldata manifest) external pure returns (bytes32) {
        return keccak256(manifest);
    }
}

published

published on mainnet · 0xd940f80F4C913B58A9D2CF04eD3271637AecEc36 · tx 0xc501e61a2846bd36… · tempo (4217) · mainnet

published on mainnet · 0xB92B723e890C0Aa3760995bA1E2B189175700d28 · tx 0x2908c7a2fc8a3f73… · base (8453) · mainnet · source as deployed

published on testnet · 0xC7F571caa076702D8Bb5611D8d6F22bD86161c5F · tx 0x2e1f4b7af748beea… · tempo (42431) · testnet

published on testnet · 0x53a3dA0CB7eAc341a5FB21ab5850486096763798 · tx 0x2c5f8305e8db8bac… · base (84532) · testnet · source as deployed