@@ -43,22 +43,19 @@ function _writeSequenceLength(bytes memory share, uint32 sequenceLength) pure {
43
43
}
44
44
45
45
function _copyBytes (bytes memory buffer , uint32 cursor , bytes memory data , uint32 length ) pure returns (uint32 ) {
46
-
47
46
uint256 start = buffer.length - length;
48
47
for (uint256 i = start; i < buffer.length ; i++ ) {
49
48
if (cursor < data.length ) {
50
49
buffer[i] = data[cursor];
51
50
cursor++ ;
52
- }
53
- else {
51
+ } else {
54
52
buffer[i] = 0 ;
55
53
}
56
54
}
57
55
return cursor;
58
56
}
59
57
60
58
function _bytesToHexString (bytes memory buffer ) pure returns (string memory ) {
61
-
62
59
// Fixed buffer size for hexadecimal convertion
63
60
bytes memory converted = new bytes (buffer.length * 2 );
64
61
@@ -73,15 +70,18 @@ function _bytesToHexString(bytes memory buffer) pure returns (string memory) {
73
70
}
74
71
75
72
// Share Version 0
76
- function _bytesToSharesV0 (bytes memory blobData , Namespace memory namespace ) pure returns (bytes [] memory shares , bool err ) {
73
+ function _bytesToSharesV0 (bytes memory blobData , Namespace memory namespace )
74
+ pure
75
+ returns (bytes [] memory shares , bool err )
76
+ {
77
77
if (namespace.version != 0 ) {
78
78
return (new bytes [](0 ), true );
79
79
}
80
80
if (isReservedNamespace (namespace)) {
81
81
return (new bytes [](0 ), true );
82
82
}
83
83
// Allocate memory for the shares
84
- uint256 numShares = _numShares (blobData.length );
84
+ uint256 numShares = _numShares (blobData.length );
85
85
bytes [] memory _shares = new bytes [](numShares);
86
86
for (uint256 i = 0 ; i < _shares.length ; i++ ) {
87
87
_shares[i] = new bytes (512 );
@@ -149,18 +149,16 @@ function _merkleMountainRangeSizes(uint256 totalSize, uint256 maxTreeSize) pure
149
149
uint256 numTrees;
150
150
if (leftovers == 0 ) {
151
151
numTrees = bigTrees;
152
- }
153
- else {
154
- numTrees = bigTrees + MathUpgradeable.log2 (leftovers) + (leftovers% 2 );
152
+ } else {
153
+ numTrees = bigTrees + MathUpgradeable.log2 (leftovers) + (leftovers % 2 );
155
154
}
156
155
uint256 [] memory treeSizes = new uint256 [](numTrees);
157
156
uint256 count = 0 ;
158
157
while (totalSize != 0 ) {
159
158
if (totalSize >= maxTreeSize) {
160
159
treeSizes[count] = maxTreeSize;
161
160
totalSize -= maxTreeSize;
162
- }
163
- else {
161
+ } else {
164
162
uint256 treeSize = _roundDownPowerOfTwo (totalSize);
165
163
treeSizes[count] = treeSize;
166
164
totalSize -= treeSize;
@@ -203,12 +201,15 @@ function _createCommitment(bytes[] memory shares, Namespace memory namespace) re
203
201
leafNamespaceNodes[j] = leafDigest (namespace, leafSets[i][j]);
204
202
}
205
203
//NamespaceMerkleMultiproof memory emptyProof = NamespaceMerkleMultiproof(0, leafSets[i].length, new NamespaceNode[](0));
206
- NamespaceMerkleMultiproof memory emptyProof = NamespaceMerkleMultiproof (0 , leafSets[i].length , leafNamespaceNodes);
207
- (NamespaceNode memory root ,,,) = NamespaceMerkleTree._computeRoot (emptyProof, leafNamespaceNodes, 0 , leafNamespaceNodes.length , 0 , 0 );
204
+ NamespaceMerkleMultiproof memory emptyProof =
205
+ NamespaceMerkleMultiproof (0 , leafSets[i].length , leafNamespaceNodes);
206
+ (NamespaceNode memory root ,,,) =
207
+ NamespaceMerkleTree._computeRoot (emptyProof, leafNamespaceNodes, 0 , leafNamespaceNodes.length , 0 , 0 );
208
208
subtreeRoots[i] = bLeafDigest (bytes (abi.encodePacked (root.min.toBytes (), root.max.toBytes (), root.digest)));
209
209
}
210
210
//BinaryMerkleMultiproof memory nullBinaryProof = BinaryMerkleMultiproof(new bytes32[](0), 0, 0);
211
211
BinaryMerkleMultiproof memory emptyBinaryProof = BinaryMerkleMultiproof (new bytes32 [](0 ), 0 , subtreeRoots.length );
212
- (bytes32 binaryTreeRoot ,,,) = BinaryMerkleTree._computeRootMulti (emptyBinaryProof, subtreeRoots, 0 , subtreeRoots.length , 0 , 0 );
212
+ (bytes32 binaryTreeRoot ,,,) =
213
+ BinaryMerkleTree._computeRootMulti (emptyBinaryProof, subtreeRoots, 0 , subtreeRoots.length , 0 , 0 );
213
214
commitment = binaryTreeRoot;
214
- }
215
+ }
0 commit comments