EncodePrivateKey encode private to key to string format.
(key *asymmetric.PrivateKey, masterKey []byte)
| 128 | |
| 129 | // EncodePrivateKey encode private to key to string format. |
| 130 | func EncodePrivateKey(key *asymmetric.PrivateKey, masterKey []byte) (keyBytes []byte, err error) { |
| 131 | serializedKey := key.Serialize() |
| 132 | encKey, err := symmetric.EncryptWithPassword(serializedKey, masterKey, privateKDFSalt) |
| 133 | if err != nil { |
| 134 | return |
| 135 | } |
| 136 | |
| 137 | keyBytes = []byte(base58.CheckEncode(encKey, PrivateKeyStoreVersion)) |
| 138 | |
| 139 | return |
| 140 | } |
| 141 | |
| 142 | // SavePrivateKey saves private key with its hash on the head to keyFilePath, |
| 143 | // default perm is 0600. |
no test coverage detected