SHA-3如何与坚固的映射一起使用?

发布于 2025-02-11 22:40:56 字数 188 浏览 0 评论 0原文

我很难理解映射的坚固性工作。正如我向我解释的那样,使用sha-3将其传递到映射的值。一旦被哈希,新的哈希值将用作存储在内存中的位置。我很困惑,因为我不明白为什么SHA-3在内存中产生真实位置。 SHA-3不会产生固定长度的随机值吗?如果SHA-3应该产生任意值,则如何使用哈希值来告诉计算机在内存中的值?谢谢。

I'm having some trouble understanding how mapping works in Solidity. As it was explained to me, the value passed into the mapping is hashed using SHA-3. Once it's hashed, the new hashed value is used as the location of where in memory the value is stored. I'm confused because I don't understand why SHA-3 is producing a real location in memory. Doesn't SHA-3 produce random values of a fixed length? How could the hashed value possibly be used to tell the computer where a value is in memory if SHA-3 is supposed to produce arbitrary values? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尘世孤行 2025-02-18 22:40:56

使用sha-3哈希传递到映射的值。

value 没有哈希。但是 - 存储插槽位置由合同中财产位置的哈希确定,而其他因素很少,例如键的索引和数据类型。

请参阅 docs for for细节。您可能对本节开始感兴趣

与映射密钥相对应的值k位于keccak256(h(k)。p)

the value passed into the mapping is hashed using SHA-3.

The value is not hashed. However - the storage slot location is determined by a hash of the property position within the contract and few other factors, such as index and datatype of the key.

See the docs for specifics. You might be interested in the section starting

The value corresponding to a mapping key k is located at keccak256(h(k) . p)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文