Remove keypath and set version to 1 for network keystorage.

This commit is contained in:
cheatfate 2020-09-30 14:04:54 +03:00 committed by zah
parent 9441e912cb
commit dd8b73c85c
2 changed files with 7 additions and 12 deletions

View File

@ -113,7 +113,6 @@ type
crypto*: Crypto crypto*: Crypto
description*: ref string description*: ref string
pubkey*: lcrypto.PublicKey pubkey*: lcrypto.PublicKey
path*: KeyPath
uuid*: string uuid*: string
version*: int version*: int
@ -630,7 +629,6 @@ proc createNetKeystore*(kdfKind: KdfKind,
rng: var BrHmacDrbgContext, rng: var BrHmacDrbgContext,
privKey: lcrypto.PrivateKey, privKey: lcrypto.PrivateKey,
password = KeystorePass "", password = KeystorePass "",
path = KeyPath "",
description = "", description = "",
salt: openarray[byte] = @[], salt: openarray[byte] = @[],
iv: openarray[byte] = @[]): NetKeystore = iv: openarray[byte] = @[]): NetKeystore =
@ -643,10 +641,9 @@ proc createNetKeystore*(kdfKind: KdfKind,
NetKeystore( NetKeystore(
crypto: cryptoField, crypto: cryptoField,
pubkey: pubKey, pubkey: pubKey,
path: path,
description: newClone(description), description: newClone(description),
uuid: $uuid, uuid: $uuid,
version: 4 version: 1
) )
proc createKeystore*(kdfKind: KdfKind, proc createKeystore*(kdfKind: KdfKind,

View File

@ -120,9 +120,8 @@ const
}, },
"description":"PBKDF2 Network private key storage", "description":"PBKDF2 Network private key storage",
"pubkey":"08021221031873e6f4e1bf837b93493d570653cb219743d4fab0ff468d4e005e1679730b0b", "pubkey":"08021221031873e6f4e1bf837b93493d570653cb219743d4fab0ff468d4e005e1679730b0b",
"path":"m/12381/60/0/0",
"uuid":"7a053160-1cdf-4faf-a2bb-331e1bc2eb5f", "uuid":"7a053160-1cdf-4faf-a2bb-331e1bc2eb5f",
"version":4 "version":1
}""" }"""
scryptNetVector = """{ scryptNetVector = """{
@ -155,9 +154,8 @@ const
}, },
"description":"SCRYPT Network private key storage", "description":"SCRYPT Network private key storage",
"pubkey":"08021221031873e6f4e1bf837b93493d570653cb219743d4fab0ff468d4e005e1679730b0b", "pubkey":"08021221031873e6f4e1bf837b93493d570653cb219743d4fab0ff468d4e005e1679730b0b",
"path":"m/12382/60/0/0",
"uuid":"83d77fa3-86cb-466a-af11-eeb338b0e258", "uuid":"83d77fa3-86cb-466a-af11-eeb338b0e258",
"version":4 "version":1
}""" }"""
password = string.fromBytes hexToSeqByte("7465737470617373776f7264f09f9491") password = string.fromBytes hexToSeqByte("7465737470617373776f7264f09f9491")
secretBytes = hexToSeqByte "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" secretBytes = hexToSeqByte "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
@ -223,8 +221,8 @@ suiteReport "KeyStorage testing suite":
let nkeystore = createNetKeystore(kdfPbkdf2, rng[], nsecret, let nkeystore = createNetKeystore(kdfPbkdf2, rng[], nsecret,
KeystorePass password, KeystorePass password,
salt = salt, iv = iv, salt = salt, iv = iv,
description = "PBKDF2 Network private key storage", description =
path = validateKeyPath("m/12381/60/0/0").expect("Valid keypath")) "PBKDF2 Network private key storage")
var var
encryptJson = parseJson Json.encode(nkeystore) encryptJson = parseJson Json.encode(nkeystore)
pbkdf2Json = parseJson(pbkdf2NetVector) pbkdf2Json = parseJson(pbkdf2NetVector)
@ -250,8 +248,8 @@ suiteReport "KeyStorage testing suite":
let nkeystore = createNetKeystore(kdfScrypt, rng[], nsecret, let nkeystore = createNetKeystore(kdfScrypt, rng[], nsecret,
KeystorePass password, KeystorePass password,
salt = salt, iv = iv, salt = salt, iv = iv,
description = "SCRYPT Network private key storage", description =
path = validateKeyPath("m/12382/60/0/0").expect("Valid keypath")) "SCRYPT Network private key storage")
var var
encryptJson = parseJson Json.encode(nkeystore) encryptJson = parseJson Json.encode(nkeystore)
pbkdf2Json = parseJson(scryptNetVector) pbkdf2Json = parseJson(scryptNetVector)