chiru-labs/ERC721A

Question regarding bit masks

Walodja1987 opened this issue · 1 comments

Hi,

I have seen Bit masks being used in connection with inline assembly. I've seen it done in the 0x protocol repo and also in this repo. I was not able to find the answer on the web why this is done.

I know what a bit mask is and that the and operation renders any byte outside of the corresponding range to zero. My question is why this is needed, i.e. in which case would an address written into a memory slot have the remaining 96 bytes not all being zero?

Appreciate your help as I am trying to implement something very similar to 0x protocol for my project (DIVA Protocol) and want to make sure I fully understand it.

Ok, I found an answer after receiving the hint to search for ”dirty upper bits“: https://docs.soliditylang.org/en/v0.8.17/security-considerations.html#minor-details