Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove trailing commas from keystore json #2200

Merged
merged 9 commits into from
Dec 1, 2023
34 changes: 16 additions & 18 deletions waku/waku_keystore/keyfile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -373,24 +373,22 @@ proc createKeyFileJson*(secret: openArray[byte],

let params = ? kdfParams(kdfkind, toHex(salt, true), workfactor)

let json = %*
{
"crypto": {
"cipher": $cryptkind,
"cipherparams": {
"iv": toHex(iv, true)
},
"ciphertext": toHex(ciphertext, true),
"kdf": $kdfkind,
"kdfparams": params,
"mac": toHex(mac.data, true),
},
}

if IdInKeyfile:
json.add("id", %($u))
if VersionInKeyfile:
json.add("version", %version)
let json = %* (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno if it the best way to address it 🤷‍♂️

"{" &
" crypto: {" &
" cipher: " & $cryptkind & "," &
" cipherparams: {" &
" iv: " & toHex(iv, true) &
" }," &
" ciphertext: " & toHex(ciphertext, true) & "," &
" kdf: " & $kdfkind & "," &
" kdfparams: " & $params & "," &
" mac: " & toHex(mac.data, true) &
" }" &
(if IdInKeyfile: ", id: " & $u else: "") &
(if VersionInKeyfile: ", version: " & $version else: "") &
"}"
)

ok(json)

Expand Down
Loading