store proofs using publicly accessible storage
Closed this issue · 3 comments
janfilips commented
See this -
contracts/notary.sol
// TODO: replace this with storage, this needs to be accessible from newly deployed contracts
// right now, when you deploy a new contract, all this information is being lost as it is stored in an in-memory per-contract base.
mapping (bytes32 => bool) private proofs;
The problem is that the content of the "proofs" dissapears once a new contract (with a new address) is deployed. Wee need to store this differently so that it is publicly accessible using multiple contracts.
janfilips commented
for an inspiration see this -
janfilips commented
/**
- @title IPFS hash handler
- @dev IPFS multihash handler. Does a small check to validate that a multihash is
- correct by validating the digest size byte of the hash. For example, the IPFS
- Multihash "QmPtkU87jX1SnyhjAgUwnirmabAmeASQ4wGfwxviJSA4wf" is the base58
- encoded form of the following data:
-
┌────┬────┬───────────────────────────────────────────────────────────────────┐
-
│byte│byte│ variable length hash based on digest size │
-
├────┼────┼───────────────────────────────────────────────────────────────────┤
-
│0x12│0x20│0x1714c8d0fa5dbe9e6c04059ddac50c3860fb0370d67af53f2bd51a4def656526 │
-
└────┴────┴───────────────────────────────────────────────────────────────────┘
-
▲ ▲ ▲
-
│ └───────────┐ │
- hash function digest size hash value
- we still store the data as
bytes
since it is inherently a variable length structure. - @dev See multihash format: https://git.io/vbooc
*/
contract DependentOnIPFS {
/**
- @dev Validate a multihash bytes value
*/
function isValidIPFSMultihash(bytes _multihashBytes) internal pure returns (bool) {
require(_multihashBytes.length > 2);
uint8 _size;
// There isn't another way to extract only this byte into a uint8
// solhint-disable no-inline-assembly
assembly {
// Seek forward 33 bytes beyond the solidity length value and the hash function byte
_size := byte(0, mload(add(_multihashBytes, 33)))
}
return (_multihashBytes.length == _size + 2);
}
}
janfilips commented
done