我知道网络上的安全是在私钥级别完成的,但我很想知道在智能契约上增加密码/字符串和基于时间的安全级别的安全含义。
简单的实现如下所示:
pragma solidity ^0.4.21;
contract PasswordTimeLock {
uint timelock;
bytes32 hashlock;
address owner;
string data = "hello world";
function PasswordTimeLock(string _password) public {
owner = msg.sender;
hashlock = keccak256(owner, _password);
}
function unlock(string _password) public returns (bool) {
require(keccak256(owner, _password) == hashlock);
timelock = now + 20 seconds;
return true;
}
function read() public view returns (string) {
require(now < timelock);
return data;
}
}是否公开传递给unlock函数或构造函数的实际字符串?
发布于 2018-03-12 21:50:40
正如smarx在他的评论中所说,任何人都可以读取构造函数中传递的密码。为了直接回答您的问题,是的,传递给unlock的字符串也是公开的。此外,任何人都可以直接从区块链读取data。
https://ethereum.stackexchange.com/questions/42542
复制相似问题