Sophisticated key management schemes and protocols, whose main objective is to provide secure and reliable communication. But the design of it meet some challenges in wireless sensor networks , whose intrinsic properties make it difficult. In this paper, A lightweight and high security key management based on ECC and ElGamal was proposed. In the scheme,the key pool is structured by the Hamilton algorithm ,in which a layer network model is given,each lay has a servicer and control center, and session key was generated by ElGamal key agreement. The performance and simulation analysis shows, this scheme was superior to the traditional key pre-distribution schemes, not only computation cost and communication cost could be decreased, but good network connectivity,suitable for wireless sensor networks.