← COMP5565 全部讲次
Q01

期中复习题|A 判断题

英文题干,逐题折叠中文解析、英文参考答案与适用条件。

手机上宽表格可左右滑动;自测答案默认收起,点击题目下方按钮查看。

使用边界:2026-10-13 期中复习,非官方材料;正式范围、题型、时长和开闭卷要求以讲师通知为准。保留课件版本、适用条件与补充标注。

复习资料:密码学、账户与 Gas · 共识、钱包与代币 · Solidity、调用与代理 · DApp 签名与英文作答

先做题再看解析:A 判断题 · B 单选题 · C 计算题 · D 代码推演 · E 简答与 X 选做补练

2026-10-13 Midterm · 自拟练习 A 卷 · 英文题干

使用边界:本卷根据期中前已有课件与注解编写,不是往年真题、预测卷或官方评分细则。建议限时 90 分钟、100 分,这是练习安排,不代表实际考试时长、题型或开闭卷要求。未见独立的正式范围通知;按已学内容准备,含基础回顾,不加入后半学期专题。

怎么做:先只看题面,作答后再展开本题答案;判断题用英文补一句理由,不能只猜 True / False;计算写公式、单位与条件;代码题先画调用帧和状态。每题答案与解析默认收起。末尾 X1-X6 为选做补练,不计入 100 分。

统一约定:除题目另说,Solidity 为 0.8.30、默认检查算术溢出;账户按普通 EOA 发起交易的课堂模型,不讨论账户代码委托。代码是隔离的教学片段,不是生产合约;假设有足够 gas,且不存在题面未给出的外部操作。金额计算忽略题面之外的费用。页码回查一律使用 PDF 页序。

Section Question IDs Marks Suggested time
A · True / False + reason A1-A12 24 15 min
B · Single best answer B1-B8 16 10 min
C · Calculations C1-C4 24 20 min
D · Code and execution traces D1-D4 24 30 min
E · Short answers E1-E2 12 15 min

读题词提醒:always = 无条件地总是;necessarily = 必然;sufficient = 充分;at least = 至少;strictly = 严格;effective = 实付或实际生效;cap = 上限;propagate = 向外层传播。看到限定词先圈出来,但不要把含 always 的题一律判错。

来源代号:C01 = Lecture crypto foundation.pdf;L01 = Lecture1.pdf;L02 = Lecture2.pdf;L03 = Lecture3.pdf;L04a = Lecture 4.0.pdf;L04b = Lecture 4.1.pdf;L05 = Lecture 5.pdf。页码都是 PDF 页序。来源为对应逐讲注解;标“补充”的部分另列标准文档。所有题干均为自拟。

A · 判断题

每题 2 分:判断 1 分,准确理由或反例 1 分。Write True or False, then justify your answer in one sentence.

A1 · True / False

Ethereum’s Keccak-256 and standardized SHA3-256 are interchangeable: they always produce the same digest for the same input.

A1 · 查看答案与解析

A1 · False:Keccak 不是可随意替换的 SHA3-256

推理过程:① 256 位只说明摘要的长度。② 算法内部的域分隔与填充规则不同,同一输入不应被当成会产生同一结果。③ 题目要求“可互换且总相同”,长度相同不足以支持这个结论。这里的 digest 统一读作“摘要”,即哈希计算的输出。

English: They use different domain-separation/padding conventions and are not interchangeable.

都是 256 位输出不代表同一算法。不要把 keccak256 换成标准库的 SHA3-256 后期待 ABI selector、地址或存储寻址结果一致。限定词:interchangeable / always。回查 C01 p.8、p.25 的哈希对照及补充说明。

A2 · True / False

A correctly verified digital signature can support message integrity and authentication relative to a trusted public key, but it does not encrypt the message.

A2 · 查看答案与解析

A2 · True:验签不等于加密

推理过程:① 用可信公钥验签,核对的是消息与签名是否匹配。② 消息被改后,原签名通常不能再通过对应验证,这支持完整性(integrity)。③ 消息仍可公开可读,所以没有因此获得机密性(confidentiality)。身份认证(authentication)还依赖公钥确实属于预期对象。

English: Verification supports integrity and authentication relative to the trusted key; it does not provide message confidentiality.

公钥必须正确关联到预期签名者;“验签通过”不能凭空证明现实世界身份或消息内容真实。反例:公开交易既能被验签,也能被所有人阅读。回查 C01 数字签名节。

A3 · True / False

In the account-state model, a block’s state root commits to the resulting world state, not merely to the list of transactions in that block.

A3 · 查看答案与解析

A3 · True:state root 和 transaction root 分工不同

推理过程:① 交易是“请执行这项操作”的请求。② 执行后,余额和合约数据等记录形成新的状态。③ state root(状态根)用于核验这份执行后的世界状态;transaction root(交易根)对应本块的交易集合及顺序。“承诺”在这里指哈希绑定的数据,不是保证业务一定成功。

English: The state root commits to the resulting account state, whereas the transaction root commits to the transactions in that block.

区分 state(执行后的状态)和 transaction(状态转移请求)。不能用“本块交易清单”替代“全局状态承诺”。回查 L02 p.29-33。

A4 · True / False

A transaction offering a higher effective priority fee must execute before every transaction offering a lower one.

A4 · 查看答案与解析

A4 · False:激励不是排序保证

推理过程:先找一个满足题设的反例:同一账户先发低交易序号的交易,再发高交易序号且小费更高的交易。后者不能为了抢先而跳过前面的序号要求。因此 effective priority fee(实际生效的小费单价)更高能提供激励,却不能推出题干的 must execute before。

English: A higher tip is an incentive, not an ordering guarantee; nonce constraints and block-builder choices still matter.

同一发送者低 nonce 的交易必须先处理;不同发送者也不能仅凭费率断言最终顺序。限定词:must / every。回查 L02 p.41、p.54-55;补充 EIP-1559。

A5 · True / False

An included transaction that executes REVERT still pays for gas consumed; it need not consume all of its gas limit.

A5 · 查看答案与解析

A5 · True:REVERT 可以保留未耗尽的 gas

推理过程:把两件事分开:REVERT 撤销失败执行造成的状态写入、转账等效果;但撤销前计算已经发生,所以已消耗 gas 仍计费。若停止时还有 unused gas(未消耗 gas),它不因 REVERT 自动全部耗尽。gas limit 是用量上限,不是失败交易必交的计费用量。

English: REVERT rolls back the failing execution’s effects while preserving unused gas; consumed gas remains chargeable.

不要混淆 unused gas 和已经花掉的 gas。顶层交易失败也不把发送者已付的 gas 全部退回。回查 L02 p.43、p.57;L04b p.55-59。

A6 · True / False

Marking a Solidity state variable private makes its value confidential from blockchain observers.

A6 · 查看答案与解析

A6 · False:private 是语言访问限制

推理过程:① private 限制其他合约或派生合约怎样在 Solidity 代码中访问该变量。② 变量仍属于公开链上的存储记录,private 没有把这些字节加密。③ 所以“不能通过某个语言入口直接读”不能推出“链上观察者无法知道内容”。getter 是自动读取函数,不是保密开关。

English: Private restricts Solidity-level access; it does not encrypt public-chain storage.

没有自动生成 getter,不等于观察者读不到链上数据。回查 L04b p.33;L03 p.10-14。依据 Solidity 安全说明。

A7 · True / False

An external contract call can transfer control to another contract before the caller finishes its own function.

A7 · 查看答案与解析

A7 · True:外部调用可以交出控制权

推理过程:设 B 正在执行提款:B 调用接收方 C 时,B 会等待这次调用返回;C 的代码在这段时间里可以再调 B。于是 B 的第一次执行还没结束,就发生第二次进入,这叫重入(reentrancy)。不变量指本应成立的账目关系,例如已提走的金额不应继续显示为可提额度。

English: The callee may execute code and call back before the caller completes, so state invariants must hold at that boundary.

是“可以重入”,不是“每次外部调用都一定被攻击”。外部控制权转移也不只发生在转 ETH 时。回查 L04b p.66、p.74 后重入补充。

A8 · True / False

A BIP32 extended public key alone can derive a hardened child public key.

A8 · 查看答案与解析

A8 · False:xpub 不能跨硬化边界

推理过程:xpub 是扩展公钥,包含公钥与 chain code(链码,派生计算的配套数据)。先看题目限定“只有 xpub”,再看子索引是硬化还是非硬化:非硬化规则允许公开派生子公钥;硬化规则需要私钥材料。因此不能从前一种能力推出后一种能力,“硬化”也不是硬件钱包的意思。

English: Public child derivation supports non-hardened indices; hardened derivation requires private-key material.

Extended public key 包含公钥与 chain code;仍不能只凭它算硬化子公钥。回查 L03 p.45-48、p.55 与补充;BIP32。

A9 · True / False

BIP39 seed derivation uses both the mnemonic and the optional passphrase; the mnemonic alone does not identify the intended seed when a nonempty passphrase was used.

A9 · 查看答案与解析

A9 · True:助记词不总是完整恢复信息

推理过程:按生成链顺推:助记词与 passphrase(可选附加口令)一起参与生成 seed(种子);种子再按派生路径生成密钥。题设用了非空附加口令,只恢复助记词就少了一个输入,不能确定原来的种子。钱包软件的本地解锁密码不自动等于这个附加口令。

English: The optional passphrase participates in seed derivation; restoring the intended wallet requires the same passphrase and compatible derivation settings.

除 passphrase,还应匹配钱包的派生路径等设置。本题不要求提供任何真实助记词或密钥。回查 L03 p.51-56;BIP39。

A10 · True / False

During delegatecall, address(this) is the implementation contract’s address.

A10 · 查看答案与解析

A10 · False:delegatecall 保留调用方上下文

推理过程:先分开“代码提供者”和“执行现场”:Logic 提供代码,Proxy 通过委托调用(delegatecall)使用它;当前地址与持久存储仍属于 Proxy。因此 address(this) 返回 Proxy。调用上下文就是这次执行的地址、存储、sender、value 等信息,不随代码来源一起改成 Logic。

English: The implementation’s code executes in the delegating contract’s context, so address(this) is the proxy here.

代码从哪来与谁的地址、存储、余额是不同问题。反例就是 Proxy 调用 Logic;也不能把保留 msg.sender 误记为“永远是最外层 EOA”。回查 L04b p.68-73、L05 p.18-23。

A11 · True / False

Using EIP-712 automatically makes every signed authorization single-use, even if the application keeps no replay-prevention state.

A11 · 查看答案与解析

A11 · False:结构化签名不是自动一次性授权

推理过程:把同一份有效签名提交两次:若第一次只验签、没有记录授权编号已用,第二次仍会通过同样的验签。域分隔(domain separation)约束授权适用的链与合约等范围;一次性还要求应用核验并消费授权 nonce。“消费”就是在成功处理路径把编号记为已用。

English: EIP-712 defines typed signing and domain separation; the application must implement its own replay prevention.

签入 nonce 但不核对、不消费,仍可重放。回查 L05 p.60-64 的适用条件;EIP-712。

A12 · True / False

An IPFS content identifier can support content-integrity verification without guaranteeing that someone will keep serving the content.

A12 · 查看答案与解析

A12 · True:完整性不等于可用性

推理过程:先问“拿到的内容对不对”,CID(内容标识符)可帮助核验这一点;再问“有没有人把内容发给我”,这取决于存储与提供内容的参与者。没人提供文件时,下载会失败,即使哈希校验规则完全正常。完整性是核对内容,可用性是能够取到内容,永久保存又是更强的要求。

English: Content addressing helps verify what was retrieved, but availability still depends on storage and serving participants.

能核对内容,不代表一定有人保存并提供它。回查 L04a p.9-10 及补充。区分:integrity / availability / permanence。

作答后怎么复盘

先记录错题号,再分成 概念 / 英文限定词 / 算术与单位 / 调用帧与状态 / 版本与条件 五类。展开对应题目的解析看错因,遮住答案后换一组数字或条件再答一次。不要只背 T/F 和选项字母。

下一页 →
Q02 期中复习题|B 单选题

个人整理的学习笔记,不是官方材料;数字与结论以课件和讲师为准。