From efafa4391021f1c90b20127bb989f51c0ae9b16b Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Wed, 18 Oct 2023 16:27:42 +0200 Subject: [PATCH] Remove PoR parameters, add merkle root for storage proofs --- contracts/Requests.sol | 15 ++------------- test/examples.js | 9 +-------- test/ids.js | 14 ++------------ 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/contracts/Requests.sol b/contracts/Requests.sol index 71c7fe3..6a96ba3 100644 --- a/contracts/Requests.sol +++ b/contracts/Requests.sol @@ -23,19 +23,8 @@ struct Ask { } struct Content { - string cid; // content id (if part of a larger set, the chunk cid) - Erasure erasure; // Erasure coding attributes - 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 + string cid; // content id, used to download the dataset + bytes merkleRoot; // merkle root of the dataset, used to verify storage proofs } enum RequestState { diff --git a/test/examples.js b/test/examples.js index 9096a8e..167b610 100644 --- a/test/examples.js +++ b/test/examples.js @@ -32,14 +32,7 @@ const exampleRequest = async () => { }, content: { cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob", - erasure: { - totalChunks: 12, - }, - por: { - u: Array.from(randomBytes(480)), - publicKey: Array.from(randomBytes(96)), - name: Array.from(randomBytes(512)), - }, + merkleRoot: Array.from(randomBytes(32)) }, expiry: now + hours(1), nonce: hexlify(randomBytes(32)), diff --git a/test/ids.js b/test/ids.js index 26f065c..78bdaad 100644 --- a/test/ids.js +++ b/test/ids.js @@ -3,9 +3,7 @@ const { keccak256, defaultAbiCoder } = ethers.utils function requestId(request) { const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, int64)" - const Erasure = "tuple(uint64)" - const PoR = "tuple(bytes, bytes, bytes)" - const Content = "tuple(string, " + Erasure + ", " + PoR + ")" + const Content = "tuple(string, bytes)" const Request = "tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)" 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) { - return [content.cid, erasureToArray(content.erasure), porToArray(content.por)] + return [content.cid, content.merkleRoot] } function requestToArray(request) {