github.com/deroproject/derosuite@v2.1.6-1.0.20200307070847-0f2e589c7a2b+incompatible/walletapi/key_to_key.go (about)

     1  package walletapi
     2  
     3  import "crypto/sha256"
     4  
     5  // all keys are derived as follows ( entirely deterministic )
     6  // ( key is derived from master secret and user supplied key)
     7  // it's only 1 way
     8  // all keys and bucket names are stored using this , except the metadata bucket
     9  // all values are stored using salsa20 aead
    10  // since all keys are dependent on the master password, almost 99.99% analsis are rendered useless
    11  func (w *Wallet) Key2Key(Key []byte) []byte {
    12  	h := sha256.New()
    13  	h.Write(w.master_password)
    14  	h.Write(Key)
    15  	hash := h.Sum(nil)
    16  	return hash[:]
    17  }