Update nexus wiki content

This commit is contained in:
2026-05-03 05:42:06 +08:00
parent 90f3811b83
commit 111bc65b7b
707 changed files with 32306 additions and 7289 deletions

72
wiki/concepts/Certora.md Normal file
View File

@@ -0,0 +1,72 @@
---
title: "Certora形式化验证工具"
type: concept
tags: [blockchain, security, smart-contract, formal-verification, tooling]
sources: [blockchain-security-auditor]
last_updated: 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 集成:
```bash
# 使用 Halmos 进行字节码级验证
forge test --match-contract CertoraTest
# 使用 Certora CLI
certora Run Vault.spec Vault.sol --prover z3 cvc5
```
## Limitations
- 需要人工编写精确的 CVL 规范(规范本身可能出错)
- 复杂合约状态空间可能导致超时
- 对外部依赖和链上状态处理有限
- 学习曲线陡峭
## Relationship to Audit
- Certora 是 [[Blockchain-Security-Auditor]] 进行 [[Formal-Verification]] 的主要工具
- 适合验证关键协议属性:份额不变性、借贷健康度、权限不变性
- 与 [[Slither]] 互补Slither 找代码模式漏洞Certora 证明数学属性
## Connections
- [[Blockchain-Security-Auditor]] ← uses ← [[Certora]]
- [[Formal-Verification]] ← implements ← [[Certora]]
- [[Halmos]] ← complementary bytecode verification ← [[Certora]]