Remove PoR parameters, add merkle root for storage proofs
This commit is contained in:
parent
14e453ac31
commit
efafa43910
|
@ -23,19 +23,8 @@ struct Ask {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Content {
|
struct Content {
|
||||||
string cid; // content id (if part of a larger set, the chunk cid)
|
string cid; // content id, used to download the dataset
|
||||||
Erasure erasure; // Erasure coding attributes
|
bytes merkleRoot; // merkle root of the dataset, used to verify storage proofs
|
||||||
PoR por; // Proof of Retrievability parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Erasure {
|
|
||||||
uint64 totalChunks; // the total number of chunks in the larger data set
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PoR {
|
|
||||||
bytes u; // parameters u_1..u_s
|
|
||||||
bytes publicKey; // public key
|
|
||||||
bytes name; // random name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RequestState {
|
enum RequestState {
|
||||||
|
|
|
@ -32,14 +32,7 @@ const exampleRequest = async () => {
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",
|
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",
|
||||||
erasure: {
|
merkleRoot: Array.from(randomBytes(32))
|
||||||
totalChunks: 12,
|
|
||||||
},
|
|
||||||
por: {
|
|
||||||
u: Array.from(randomBytes(480)),
|
|
||||||
publicKey: Array.from(randomBytes(96)),
|
|
||||||
name: Array.from(randomBytes(512)),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
expiry: now + hours(1),
|
expiry: now + hours(1),
|
||||||
nonce: hexlify(randomBytes(32)),
|
nonce: hexlify(randomBytes(32)),
|
||||||
|
|
14
test/ids.js
14
test/ids.js
|
@ -3,9 +3,7 @@ const { keccak256, defaultAbiCoder } = ethers.utils
|
||||||
|
|
||||||
function requestId(request) {
|
function requestId(request) {
|
||||||
const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, int64)"
|
const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, int64)"
|
||||||
const Erasure = "tuple(uint64)"
|
const Content = "tuple(string, bytes)"
|
||||||
const PoR = "tuple(bytes, bytes, bytes)"
|
|
||||||
const Content = "tuple(string, " + Erasure + ", " + PoR + ")"
|
|
||||||
const Request =
|
const Request =
|
||||||
"tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)"
|
"tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)"
|
||||||
return keccak256(defaultAbiCoder.encode([Request], requestToArray(request)))
|
return keccak256(defaultAbiCoder.encode([Request], requestToArray(request)))
|
||||||
|
@ -23,16 +21,8 @@ function askToArray(ask) {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function erasureToArray(erasure) {
|
|
||||||
return [erasure.totalChunks]
|
|
||||||
}
|
|
||||||
|
|
||||||
function porToArray(por) {
|
|
||||||
return [por.u, por.publicKey, por.name]
|
|
||||||
}
|
|
||||||
|
|
||||||
function contentToArray(content) {
|
function contentToArray(content) {
|
||||||
return [content.cid, erasureToArray(content.erasure), porToArray(content.por)]
|
return [content.cid, content.merkleRoot]
|
||||||
}
|
}
|
||||||
|
|
||||||
function requestToArray(request) {
|
function requestToArray(request) {
|
||||||
|
|
Loading…
Reference in New Issue