Attestable contract provides attester management and signature verification functionality for Cross-Chain Transfer Protocol messages. It implements an m-of-n multisig mechanism where m attesters must sign messages for them to be considered valid.
Contract: src/roles/Attestable.sol
Key Concepts
- Attesters: Authorized signers who can attest to message validity
- Signature Threshold: Minimum number of signatures required (m in m/n multisig)
- Attester Manager: Role responsible for managing attesters and threshold
State Variables
signatureThreshold
enabledAttesters
Functions
enableAttester
newAttester: Address of the attester to enable
- Caller must be the attester manager
- New attester must be non-zero address
- Attester must not already be enabled
AttesterEnabled(address indexed attester)
Source: Attestable.sol:100
disableAttester
attester: Address of the attester to disable
- Caller must be the attester manager
- Must have more than one enabled attester
- Number of enabled attesters must exceed signature threshold
- Attester must currently be enabled
AttesterDisabled(address indexed attester)
Source: Attestable.sol:138
setSignatureThreshold
newSignatureThreshold: New signature threshold value
- Caller must be the attester manager
- New threshold must be non-zero
- New threshold must not exceed number of enabled attesters
- New threshold must be different from current threshold
SignatureThresholdUpdated(uint256 oldSignatureThreshold, uint256 newSignatureThreshold)
Source: Attestable.sol:161
updateAttesterManager
newAttesterManager: Address of the new attester manager
- Caller must be the owner
- New attester manager must be non-zero address
AttesterManagerUpdated(address indexed previousAttesterManager, address indexed newAttesterManager)
Source: Attestable.sol:125
isEnabledAttester
attester: Address to check
true if the address is an enabled attester, false otherwise
Source: Attestable.sol:109
getNumEnabledAttesters
getEnabledAttester
index: Index of the attester in the set
attesterManager
Signature Verification
Internal Verification
The contract includes internal signature verification logic:- Attestation length must equal
signatureLength * signatureThreshold(65 bytes per signature) - Recovered addresses must be in increasing order (prevents duplicates)
- All signers must be enabled attesters
- Uses ECDSA signature recovery
Modifiers
onlyAttesterManager
Events
AttesterEnabled
AttesterDisabled
SignatureThresholdUpdated
AttesterManagerUpdated
Usage Example
Security Considerations
- The signature threshold must always be less than or equal to the number of enabled attesters
- Cannot disable attesters if it would reduce the count below the threshold
- Must maintain at least one enabled attester at all times
- Signatures must be provided in ascending order by signer address to prevent duplicates
- Uses ECDSA signature recovery from OpenZeppelin for security