Files
nexus/wiki/concepts/Certora.md
2026-05-03 05:42:12 +08:00

2.2 KiB
Raw Blame History

title, type, tags, sources, last_updated
title type tags sources last_updated
Certora形式化验证工具 concept
blockchain
security
smart-contract
formal-verification
tooling
blockchain-security-auditor
2026-05-30

Aliases

  • Certora
  • Certora Prover
  • Certora Verification System

Definition

Certora 是一个基于符号执行Symbolic Execution的智能合约形式化验证工具通过 CVLCertora Verification Language描述协议规范系统性证明 Solidity 合约的关键属性是否在所有可能状态下成立。与测试不同Certora 可以证明某个属性在数学上不可能被违反

Key Capabilities

  • 属性证明验证合约不变性invariant在所有执行路径上成立
  • 反例生成:当属性无法被证明时,自动生成导致属性失败的最小执行序列
  • 多合约分析:支持分析调用关系复杂的合约系统
  • 并行验证:可并行验证多条规则

CVL Example

rule noUnauthorizedWithdrawal(method f) {
    env e;
    calldataarg args;

    require f != nop; // 排除空调用

    // 如果调用成功,则调用者必须是所有者
    f(e, args);
    assert e.msg.sender == owner, "Unauthorized withdrawal";
}

invariant totalSupplyInvariant() {
    // 总供应量恒定
    invariant totalSupply == init(totalSupply);
}

Integration with Foundry

Certora 可与 Foundry 集成:

# 使用 Halmos 进行字节码级验证
forge test --match-contract CertoraTest

# 使用 Certora CLI
certora Run Vault.spec Vault.sol --prover z3 cvc5

Limitations

  • 需要人工编写精确的 CVL 规范(规范本身可能出错)
  • 复杂合约状态空间可能导致超时
  • 对外部依赖和链上状态处理有限
  • 学习曲线陡峭

Relationship to Audit

Connections