CodeChain-io/codechain-keystore-js

Why is secret stringified when stored?

sgkim126 opened this issue · 1 comments

Currently, the keystore format looks like a below. I can't find a reason to stringify the secret field.

{
  "platform_keys": [
    {
      "secret": "{\"crypto\":{\"ciphertext\":\"e5bc2edb24c39ca7ab93797de1c69bff4bc10116307a4c709fa03964cb1f05c9\",\"cipherparams\":{\"iv\":\"f95cc95d42f23d3dc23fd806e0dda5b4\"},\"cipher\":\"aes-128-ctr\",\"kdf\":\"pbkdf2\",\"kdfparams\":{\"dklen\":32,\"salt\":\"fad7cf1a0bb90752a7c8670b192f7257c6d16807e1290cf8915fd09d5dd47ab5\",\"c\":262144,\"prf\":\"hmac-sha256\"},\"mac\":\"9af7457f7eb41537182bcdc704471f3f08e6ea5ee6af15e8df63f93920b7ee2c\"},\"id\":\"e4fa910b-b6ea-411b-9e34-cde4241beb94\",\"version\":3}",
      "publicKey": "b1d9d3079416c50a1ed51b9a7b6bfe5966a158a4b65d9a51472134cba26ca7ff00bbc7a76c023b879a2abac199c9b7d9fb5fbb25bc31850d06dfa9362f68d8f7"
    }
  ],
  "asset_keys": [],
  "mapping": {
    "09880ce815b65b3f73a1ffad14e3fb6bbee7f380": "b1d9d3079416c50a1ed51b9a7b6bfe5966a158a4b65d9a51472134cba26ca7ff00bbc7a76c023b879a2abac199c9b7d9fb5fbb25bc31850d06dfa9362f68d8f7"
  }
}

I suppose that database is a key-value store only stores string data.
But we use a JSON file to store it.
We don't need to stringify it now.