Security of chip-scale quantum key distribution