Skip to content

Commit ce1c5ad

Browse files
committed
remove auxiliary utils
1 parent bef2e4f commit ce1c5ad

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

contracts/utils/Base58.sol

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ library Base58 {
163163
uint256[] memory outi = new uint256[](outiLength);
164164
for (uint256 i = 0; i < data.length; ++i) {
165165
// get b58 char
166-
uint8 chr = _mload8i(data, i);
166+
uint8 chr = uint8(data[i]);
167167
require(chr > 48 && chr < 123, InvalidBase56Digit(chr));
168168

169169
// decode b58 char
170-
uint256 carry = _mload8i(cache, chr - 49);
170+
uint256 carry = uint8(cache[chr - 49]);
171171
require(carry < 58, InvalidBase56Digit(chr));
172172

173173
for (uint256 j = outiLength; j > 0; --j) {
@@ -182,8 +182,8 @@ library Base58 {
182182
for (uint256 j = 0; j < outiLength; ++j) {
183183
while (mask > 0) {
184184
--mask;
185-
_mstore8(binu, ptr, bytes1(uint8(outi[j] >> (8 * mask))));
186-
ptr++;
185+
binu[ptr] = bytes1(uint8(outi[j] >> (8 * mask)));
186+
++ptr;
187187
}
188188
mask = 4;
189189
}
@@ -193,32 +193,4 @@ library Base58 {
193193
return binu.splice(msb * (dataLeadingZeros + msb < binu.length).toUint(), ptr);
194194
}
195195
}
196-
197-
function _mload8(bytes memory buffer, uint256 offset) private pure returns (bytes1 value) {
198-
// This is not memory safe in the general case, but all calls to this private function are within bounds.
199-
assembly ("memory-safe") {
200-
value := mload(add(add(buffer, 0x20), offset))
201-
}
202-
}
203-
204-
function _mload8i(bytes memory buffer, uint256 offset) private pure returns (uint8 value) {
205-
// This is not memory safe in the general case, but all calls to this private function are within bounds.
206-
assembly ("memory-safe") {
207-
value := shr(248, mload(add(add(buffer, 0x20), offset)))
208-
}
209-
}
210-
211-
function _mstore8(bytes memory buffer, uint256 offset, bytes1 value) private pure {
212-
// This is not memory safe in the general case, but all calls to this private function are within bounds.
213-
assembly ("memory-safe") {
214-
mstore8(add(add(buffer, 0x20), offset), shr(248, value))
215-
}
216-
}
217-
218-
function _mstore8i(bytes memory buffer, uint256 offset, uint8 value) private pure {
219-
// This is not memory safe in the general case, but all calls to this private function are within bounds.
220-
assembly ("memory-safe") {
221-
mstore8(add(add(buffer, 0x20), offset), value)
222-
}
223-
}
224196
}

0 commit comments

Comments
 (0)