Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Redistribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ contract Redistribution is AccessControl, Pausable {
bytes signature;
bytes32 identifier; //
bytes32 chunkAddr; // wrapped chunk address
SOCDispersedParams[] dispersedParams; // either with length 1 or 0
}

struct SOCDispersedParams {
uint8 nonce; // hashed with SOC address
}

struct PostageProof {
Expand Down Expand Up @@ -1051,10 +1056,11 @@ contract Redistribution is AccessControl, Pausable {
revert SocVerificationFailed(entryProof.socProof[0].chunkAddr);
}

if (
calculateSocAddress(entryProof.socProof[0].identifier, entryProof.socProof[0].signer) !=
entryProof.proveSegment
) {
socAddress = calculateSocAddress(entryProof.socProof[0].identifier, entryProof.socProof[0].signer);
if (entryProof.socProof[0].dispersedParams.length > 0) {
socAddress = calculateDispersedSocAddress(socAddress, entryProof.socProof[0].dispersedParams[0]);
}
if (socAddress != entryProof.proveSegment) {
revert SocCalcNotMatching(entryProof.socProof[0].chunkAddr);
}
}
Expand Down Expand Up @@ -1120,6 +1126,10 @@ contract Redistribution is AccessControl, Pausable {
return keccak256(abi.encodePacked(identifier, signer));
}

function calculateDispersedSocAddress(bytes32 socAddress, uint8 nonce) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(nonce, socAddress));
}

function checkOrder(uint256 a, uint256 b, bytes32 trA1, bytes32 trA2, bytes32 trALast) internal pure {
if (a < b) {
if (uint256(trA1) >= uint256(trA2)) {
Expand Down
Loading