verifyValue
verifyValue authenticates a signed CFB index value against the supplied expected fields.
For details on the expected, payload and signature arguments, refer to
REST API Values.
Signature and arguments
function verifyValue(
ExpectedValue calldata expected,
bytes calldata payload,
bytes calldata signature,
uint64 maxAgeMillis
) external view returns (VerifiedValue memory);
Canonical ABI signature (selector 0x4a5e951b):
verifyValue((string,uint64,bool,uint128,bytes32),bytes,bytes,uint64)
| Argument | Meaning |
|---|---|
expected | Exact expected fields in the tuple order below. |
payload | Supplied payload bytes from the API |
signature | Supplied signature from the API |
maxAgeMillis | Application-selected inclusive maximum age in milliseconds, from zero to 2,678,400,000 (31 days). |
ExpectedValue
struct ExpectedValue {
string feedId;
uint64 timeMillis;
bool negative;
uint128 magnitude;
bytes32 commitmentNonce;
}
| Field | Meaning |
|---|---|
feedId | Oracle feed identifier. |
timeMillis | Exact observation time, in milliseconds since the Unix epoch. |
negative | Whether the value is negative. |
magnitude | Absolute value scaled by 10^18. |
commitmentNonce | Supplied nonzero 32-byte reveal nonce. |
Take these fields from the API response's verification.cfbDaV1Value.expected
object. The consuming contract must also check that feedId matches the feed
required by the application. See the usage guide.
VerifiedValue
struct VerifiedValue {
string feedId;
uint64 timeMillis;
bool negative;
uint128 magnitude;
uint8 version;
}
Returns a copy of the expected values for a successfully validated value, with version = 1.
Freshness policy
Choose maxAgeMillis according to how old an observation your application can
accept. The verifier checks it against the chain clock, and rejects future observations.
Setting maxAgeMillis to zero requires exact equality:
timeMillis == block.timestamp * 1000 and is not recommended as it is sensitive
to block times.
Errors
Pause and time
| Error signature | Meaning and action |
|---|---|
EnforcedPause() | Verification is paused. Apply your application's unavailable-data policy. |
PayloadFromFuture(uint64 timeMillis, uint256 blockTimeMillis) | Wait for the chain clock to catch up or fetch eligible data. |
PayloadTooOld(uint64 timeMillis, uint256 blockTimeMillis, uint64 maxAgeMillis) | Fetch fresher signed data. |
MaxAgeMillisTooLarge(uint64 supplied, uint64 maximum) | Correct a freshness policy exceeding 2,678,400,000 milliseconds. |
DelegationOutsideValidityWindow(uint64 timeMillis, uint64 validFromMillis, uint64 validToMillis) | Payload was not valid. Obtain a correctly signed observation. |
Signatures and authorization
| Error signature | Meaning and action |
|---|---|
InvalidSignatureLength(uint256 length) | Signature was not valid. Check the supplied signature is unchanged. |
InvalidSignature() | Signature was not valid. Check that payload and signature belong together. |
InvalidDelegationCertificate() | Payload was not valid. Obtain valid signed data. |
UnauthorizedSigner(address signer) | The signer is not valid. Check the verifier address and contact the provider if current data cannot be verified. |
SignerRoleCollision(address signer) | The signer is not valid. Check the verifier address and contact the provider if current data cannot be verified. |
InvalidMerkleProof() | Payload was not valid. Obtain valid signed data. |
Payload and expected value
| Error signature | Meaning and action |
|---|---|
MalformedPayloadLength(uint256 actualLength, uint256 expectedLength) | Payload was not valid. Pass the supplied payload bytes unchanged. |
UnsupportedPayloadVersion(uint8 version) | This revision supports version 1. Check the API/verifier compatibility. |
InvalidMerkleProofCount(uint256 count) | Payload was not valid. Obtain valid signed data. |
MalformedMerkleProofLength(uint256 proofBytes) | Payload was not valid. Obtain valid signed data. |
InvalidFeedIdHash() | Payload was not valid. Obtain valid signed data. |
InvalidFeedId() | Supply the exact configured feed ID. |
UnexpectedFeedIdHash(bytes32 expected, bytes32 actual) | The signed feed differs from the required feed. Fetch the required feed. |
UnexpectedTimeMillis(uint64 expected, uint64 actual) | The expected timestamp differs from the signed timestamp. Keep the verification arguments together and use milliseconds. |
UnexpectedSchemeId(bytes32 expected, bytes32 actual) | The signed payload is not for the required value scheme. Obtain valid signed data. |
InvalidCommitmentNonce(bytes32 commitmentNonce) | The nonce is zero. Use the supplied nonzero nonce. |
NonCanonicalValue(bytes32 packedValue) | Negative zero is not an accepted value. Use the provided sign and magnitude. |
UnexpectedDataCommitment(bytes32 expected, bytes32 actual) | The nonce, sign and magnitude do not open the signed commitment. Check for mixed observations or lost integer precision. |