10 RLP编码中空字符串,数值0,空List为什么会依次编码为0x80,0x80,0xC0

根据黄皮书附录2中的RLP形式化定义,针对空字符串,和数值0,应该是适用于bytes array中的otherwise 条件,为什么会被编码为0x80? 针对空字符串,其长度应该为0,适用于长度小于56,则应该是编码0x80 但是针对数值0和编码后的\x00, 为什么使用条件不一样呢?编码后的\x00适用于长度为1的条件1,但是数值0为什么适用于条件2呢?

$$ R_{\mathrm{b}}(\mathbf{x}) \equiv \begin{cases} \mathbf{x} & \text{if} \quad \lVert \mathbf{x} \rVert = 1 \wedge \mathbf{x}[0] < 128 \ (128 + \lVert \mathbf{x} \rVert) \cdot \mathbf{x} &\text{else if} \quad \lVert \mathbf{x} \rVert < 56 \ \big(183 + \big\lVert \mathtt{BE}(\lVert \mathbf{x} \rVert) \big\rVert \big) \cdot \mathtt{BE}(\lVert \mathbf{x} \rVert) \cdot \mathbf{x} &\text{else if} \quad \lVert \mathbf{x} \rVert < 2^{64} \ \varnothing &\text{otherwise} \end{cases} \ \mathtt{BE}(x) \equiv (b_0, b_1, ...): b0 \neq 0 \wedge x = \sum{n = 0}^{\lVert \mathbf{b} \rVert - 1} b_n \cdot 256^{\lVert \mathbf{b} \rVert - 1 - n} \ (x_1, ..., x_n) \cdot (y_1, ..., y_m) = (x_1, ..., x_n, y_1, ..., y_m) $$

请先 登录 后评论

1 个回答

张小风
请先 登录 后评论
  • 0 关注
  • 0 收藏,1821 浏览
  • bixia1994 提出于 2021-07-09 23:36

相似问题