library NftOpenMinterMerkleTree { static function updateLeaf(bytes oldLeaf, bytes newLeaf, bytes[15] neighbor, bool[15] neighborType, bytes oldMerkleRoot) : bytes { bytes oldMerkleValue = oldLeaf; bytes newMerkleValue = newLeaf; loop (14) : i { if(neighborType[i]) { oldMerkleValue = hash160(oldMerkleValue + neighbor[i]); newMerkleValue = hash160(newMerkleValue + neighbor[i]); } else { oldMerkleValue = hash160(neighbor[i] + oldMerkleValue); newMerkleValue = hash160(neighbor[i] + newMerkleValue); } } require(oldMerkleValue == oldMerkleRoot); return newMerkleValue; } static function verifyLeaf(bytes leaf, bytes[15] neighbor, bool[15] neighborType, bytes merkleRoot) : bool { bytes merkleValue = leaf; loop (14) : i { if(neighborType[i]) { merkleValue = hash160(merkleValue + neighbor[i]); } else { merkleValue = hash160(neighbor[i] + merkleValue); } } require(merkleValue == merkleRoot); return true; } }