@@ -163,11 +163,11 @@ library Base58 {
163
163
uint256 [] memory outi = new uint256 [](outiLength);
164
164
for (uint256 i = 0 ; i < data.length ; ++ i) {
165
165
// get b58 char
166
- uint8 chr = _mload8i (data, i );
166
+ uint8 chr = uint8 (data[i] );
167
167
require (chr > 48 && chr < 123 , InvalidBase56Digit (chr));
168
168
169
169
// decode b58 char
170
- uint256 carry = _mload8i (cache, chr - 49 );
170
+ uint256 carry = uint8 (cache[ chr - 49 ] );
171
171
require (carry < 58 , InvalidBase56Digit (chr));
172
172
173
173
for (uint256 j = outiLength; j > 0 ; -- j) {
@@ -182,8 +182,8 @@ library Base58 {
182
182
for (uint256 j = 0 ; j < outiLength; ++ j) {
183
183
while (mask > 0 ) {
184
184
-- mask;
185
- _mstore8 ( binu, ptr, bytes1 (uint8 (outi[j] >> (8 * mask) )));
186
- ptr ++ ;
185
+ binu[ ptr] = bytes1 (uint8 (outi[j] >> (8 * mask)));
186
+ ++ ptr ;
187
187
}
188
188
mask = 4 ;
189
189
}
@@ -193,32 +193,4 @@ library Base58 {
193
193
return binu.splice (msb * (dataLeadingZeros + msb < binu.length ).toUint (), ptr);
194
194
}
195
195
}
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
- }
224
196
}
0 commit comments