24 个版本 (9 个稳定版)
1.0.39 | 2022年7月6日 |
---|---|
1.0.38 | 2021年6月9日 |
1.0.37 | 2021年2月25日 |
0.8.0 | 2019年9月18日 |
0.3.0-pre | 2016年10月13日 |
899 在 魔法豆
每月81次 下载
在 4 个crate(3个直接)中使用
22KB
286 行
resource_proof
crate | 文档 | CI |
---|---|---|
MaidSafe 网站 | Safe Dev 论坛 | Safe Network 论坛 |
---|
摘要
这个crate的目的是结合尝试在远程机器上验证资源的机制。然而,这种验证只是抽查,并且是尽力而为的。这并不保证随着时间的推移会准确,这一点必须清楚地告知crate的用户。
目的是提供一些表明机器具有某些能力的指示。
动机
在去中心化网络中,由于缺乏信任,一个打算加入的节点必须证明它能够满足网络的最低要求。这些资源要求由网络本身(最佳)或程序员设定。
在这样的网络中,必须假设加入的节点正在运行与现有节点不同的软件。
即使节点通过使用其他资源来帮助证明来抵消这个证明,这也可能不会有所帮助,因为网络应该使用持续的监控能力,并与这些“抽查”并行进行。
当前状态
在0.2.x版本中,这个crate执行了一些基本的检查,要求节点具有一些计算能力,并且能够传输一定量的数据(带宽检查)。
基于对Hashcash的变体,并增加了传输一定数据量的要求,这个库提供了一种类似于“工作量证明”的算法。这种工作要求迫使加入节点的节点执行一些计算和数据传输。预期的使用场景是在一定时间内完成工作并传输数据。可以提供两个证明,一个侧重于大量工作(难度),另一个侧重于带宽要求(大小)。这些在API中被组合,但不必作为单一证明使用,除非这个要求可以计算。
当前使用的哈希机制是sha3(keccak),这为机器“工作”提供了一些要求,但不是ASIC抗性。这个算法可能升级到类似于Equihash的东西,这可能会抵抗ASIC类型的解决方案,但重要的是它将允许对节点内存要求有更好的要求(这在此crate中尚未测量)。
未来也可能添加磁盘空间测量。
分析
有一个示例可以测试任何值,并允许对不同架构进行测量。这可以通过以下命令运行:cargo run --release --example analyse -- -h
这将允许用户玩难度和大小设置。难度是要求机器不断将零推到任何数据的前面,直到数据的哈希的起始位数为零。类似于一个常见的证明工作算法。
大小参数强制将提供的nonce重复,直到达到一定的字节数。然后将其作为证明传输回网络。
要找到证明,节点必须不断将零推到数据的前面(而不是后面,因为这很容易优化)。这迫使在每次哈希迭代中连续读取大量数据段。
以下是一些在台式Linux机器上的数据
小数据元素(36字节)
cargo run --release -- -d 1 -s1024 -i
Running analysis ....
Difficulty = 1 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 1
Difficulty = 2 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 4
Difficulty = 3 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 4
Difficulty = 4 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 19
Difficulty = 5 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 85
Difficulty = 6 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 85
Difficulty = 7 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 85
Difficulty = 8 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 474
Difficulty = 9 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 474
Difficulty = 10 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 474
Difficulty = 11 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 1017
Difficulty = 12 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 1017
Difficulty = 13 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 4367
Difficulty = 14 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 4367
Difficulty = 15 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 4367
Difficulty = 16 size = 1024 create = 0 seconds check = 0 seconds num of attempts = 4367
Difficulty = 17 size = 1024 create = 155 seconds check = 0 seconds num of attempts = 248184
Difficulty = 18 size = 1024 create = 154 seconds check = 0 seconds num of attempts = 248184
Difficulty = 19 size = 1024 create = 1508 seconds check = 0 seconds num of attempts = 787761
Difficulty = 20 size = 1024 create = 6087 seconds check = 0 seconds num of attempts = 1587092
约100MB数据
cargo run --release -- -d=1 -s=102400000 -i
Running analysis ....
Difficulty = 1 size = 10485760 create = 0 seconds check = 0 seconds num of attempts = 0
Difficulty = 2 size = 10485760 create = 0 seconds check = 0 seconds num of attempts = 0
Difficulty = 3 size = 10485760 create = 0 seconds check = 0 seconds num of attempts = 0
Difficulty = 4 size = 10485760 create = 0 seconds check = 0 seconds num of attempts = 0
Difficulty = 5 size = 10485760 create = 3 seconds check = 0 seconds num of attempts = 61
Difficulty = 6 size = 10485760 create = 3 seconds check = 0 seconds num of attempts = 61
Difficulty = 7 size = 10485760 create = 3 seconds check = 0 seconds num of attempts = 61
Difficulty = 8 size = 10485760 create = 3 seconds check = 0 seconds num of attempts = 61
Difficulty = 9 size = 10485760 create = 25 seconds check = 0 seconds num of attempts = 478
Difficulty = 10 size = 10485760 create = 25 seconds check = 0 seconds num of attempts = 478
Difficulty = 11 size = 10485760 create = 66 seconds check = 0 seconds num of attempts = 1268
Difficulty = 12 size = 10485760 create = 210 seconds check = 0 seconds num of attempts = 4032
Difficulty = 13 size = 10485760 create = 755 seconds check = 0 seconds num of attempts = 14860
Difficulty = 14 size = 10485760 create = 1039 seconds check = 0 seconds num of attempts = 20484
Difficulty = 15 size = 10485760 create = 1035 seconds check = 0 seconds num of attempts = 20484
Difficulty = 16 size = 10485760 create = 1849 seconds check = 0 seconds num of attempts = 36453
Difficulty = 17 size = 10485760 create = 2594 seconds check = 0 seconds num of attempts = 51130
重要的是,检查证明非常快,并且如果有足够的难度,创建证明将是劳动密集型的。这是一个关键的考虑因素,可以缓解去中心化/对等网络的一些攻击向量。这绝对不是一种安全解决方案,不应该在没有对节点的“行为”进行持续检查的情况下考虑。
许可证
此SAFE网络库根据您的选择在修改后的BSD许可证(LICENSE-BSD https://opensource.org/licenses/BSD-3-Clause)或MIT许可证(LICENSE-MIT http://opensource.org/licenses/MIT)下双许可。
贡献
想贡献?太棒了 🎉
有很多方式可以为项目做出贡献,无论是编写新代码、修复错误,还是只是报告错误。所有形式的贡献都受到鼓励!
有关如何贡献的说明,请参阅我们的贡献指南。
依赖关系
~3.5MB
~65K SLoC