hats-finance / illuminex-0x0bb4aa1f58719707405c231fcdf0b405714799cf

0 stars 1 forks source link

Missing events for _updateKeyPair, _setMinWitnessSignatures and _setWitnessPublicKeys in the TEERollup contract. #70

Open hats-bug-reporter[bot] opened 4 months ago

hats-bug-reporter[bot] commented 4 months ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0x333ee24524b9daf8df70c802935d2d6d9a8592abce5bb294ce5b29d18c5baa37 Severity: low

Description: Description\ The _updateKeyPair, _setMinWitnessSignatures and _setWitnessPublicKeys functions do not emit an event, although they should.

Recommendations\ Add events to these functions.

Attachments

  1. Proof of Concept (PoC) File

    ContractSigningKeyPair private _keyPair;
    
    mapping(bytes => bool) public witnessPublicKeysSet;
    uint8 public minWitnessSignatures;
    
    constructor() {
        _updateKeyPair();
    }
    
    function _updateKeyPair() internal {
        (bytes memory publicKey, bytes memory privateKey) = Sapphire.generateSigningKeyPair(
            Sapphire.SigningAlg.Secp256k1PrehashedKeccak256,
            Sapphire.randomBytes(32, abi.encodePacked(block.number, msg.sender))
        );
    
        _keyPair.publicKey = publicKey;
        _keyPair.privateKey = privateKey;
    }
    
    function _setMinWitnessSignatures(uint8 _min) internal {
        minWitnessSignatures = _min;
    }
    
    function _setWitnessPublicKeys(WitnessActivation[] memory _witnesses) internal {
        for (uint i = 0; i < _witnesses.length; i++) {
            witnessPublicKeysSet[_witnesses[i].publicKey] = _witnesses[i].isActive;
        }
    }
  2. Revised Code File (Optional)

    event UpdateKeyPair(bytes indexed publicKey, bytes indexed privateKey);
    
    event SetMinWitnessSignatures(uint8 indexed minWitnessSignatures);
    
    event SetWitnessPublicKeys(WitnessActivation[] indexed witnesses);
    
    ContractSigningKeyPair private _keyPair;
    
    mapping(bytes => bool) public witnessPublicKeysSet;
    uint8 public minWitnessSignatures;
    
    constructor() {
        _updateKeyPair();
    }
    
    function _updateKeyPair() internal {
        (bytes memory publicKey, bytes memory privateKey) = Sapphire.generateSigningKeyPair(
            Sapphire.SigningAlg.Secp256k1PrehashedKeccak256,
            Sapphire.randomBytes(32, abi.encodePacked(block.number, msg.sender))
        );
    
        _keyPair.publicKey = publicKey;
        _keyPair.privateKey = privateKey;
    
        emit UpdateKeyPair(_keyPair.publicKey, _keyPair.privateKey);
    }
    
    function _setMinWitnessSignatures(uint8 _min) internal {
        minWitnessSignatures = _min;
        emit SetMinWitnessSignatures(minWitnessSignatures);
    }
    
    function _setWitnessPublicKeys(WitnessActivation[] memory _witnesses) internal {
        for (uint i = 0; i < _witnesses.length; i++) {
            witnessPublicKeysSet[_witnesses[i].publicKey] = _witnesses[i].isActive;
        }
        emit SetWitnessPublicKeys(_witnesses);
    }
party-for-illuminati commented 4 months ago

Informational