Minimizing the quantity of transmitted data and protecting the devices from the adversary environment are the main challenges hindering the advancement of Internet of Things (IoT) network. Based on the theorem of unique prime factorization that any natural number can be expressed as the product of powers of prime numbers, we introduce a new scheme in this paper for secure and efficient gathering of the IoT data. The proposed scheme consists of three phases: Setup, Secure data gathering, and Data reconstruction. In the Setup phase, the properties of the prime numbers to create an efficient clustering and routing tree algorithm are utilized to reduce the power consumption during data transmission process. The Secure data gathering phase includes secure intra and inter communication procedures. During secure intra-communication procedure, the Compressive Sensing (CS) based method of data compression and encryption is used. Moreover, the prime number properties and the Bezier curve function are used to solve the CS problems. In the secure inter-communication procedure, the security performance of the IoT based Wireless Sensor Networks (WSNs) is improved by combining Private and Public key algorithms with the consideration of the power limitation of IoT devices. Finally, the proposed scheme introduces an adept reconstruction algorithm which is a hybrid algorithm of Bees and Genetic Algorithm to successfully restore the actual sensor data from the compressed samples, which improves the reconstruction process.