SavePrivateKey saves private key with its hash on the head to keyFilePath, default perm is 0600.
(keyFilePath string, key *asymmetric.PrivateKey, masterKey []byte)
| 142 | // SavePrivateKey saves private key with its hash on the head to keyFilePath, |
| 143 | // default perm is 0600. |
| 144 | func SavePrivateKey(keyFilePath string, key *asymmetric.PrivateKey, masterKey []byte) (err error) { |
| 145 | var keyBytes []byte |
| 146 | keyBytes, err = EncodePrivateKey(key, masterKey) |
| 147 | if err != nil { |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | return ioutil.WriteFile(keyFilePath, keyBytes, 0600) |
| 152 | } |
| 153 | |
| 154 | // InitLocalKeyPair initializes local private key. |
| 155 | func InitLocalKeyPair(privateKeyPath string, masterKey []byte) (err error) { |