Internet of Things security and privacy: Design methods and optimization