From 1c4c486a85ef304e060da592bf46f81d015aa662 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 17 Feb 2020 12:22:52 +0100 Subject: [PATCH] cmd/ethkey: speed up test by using weaker scrypt parameters (#20680) --- cmd/ethkey/generate.go | 10 +++++++++- cmd/ethkey/message_test.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/ethkey/generate.go b/cmd/ethkey/generate.go index fe9a0c1519..09b00cc9dc 100644 --- a/cmd/ethkey/generate.go +++ b/cmd/ethkey/generate.go @@ -52,6 +52,10 @@ If you want to encrypt an existing private key, it can be specified by setting Name: "privatekey", Usage: "file containing a raw private key to encrypt", }, + cli.BoolFlag{ + Name: "lightkdf", + Usage: "use less secure scrypt parameters", + }, }, Action: func(ctx *cli.Context) error { // Check if keyfile path given and make sure it doesn't already exist. @@ -91,7 +95,11 @@ If you want to encrypt an existing private key, it can be specified by setting // Encrypt key with passphrase. passphrase := promptPassphrase(true) - keyjson, err := keystore.EncryptKey(key, passphrase, keystore.StandardScryptN, keystore.StandardScryptP) + scryptN, scryptP := keystore.StandardScryptN, keystore.StandardScryptP + if ctx.Bool("lightkdf") { + scryptN, scryptP = keystore.LightScryptN, keystore.LightScryptP + } + keyjson, err := keystore.EncryptKey(key, passphrase, scryptN, scryptP) if err != nil { utils.Fatalf("Error encrypting key: %v", err) } diff --git a/cmd/ethkey/message_test.go b/cmd/ethkey/message_test.go index e9e8eeeafb..9d242ac002 100644 --- a/cmd/ethkey/message_test.go +++ b/cmd/ethkey/message_test.go @@ -34,7 +34,7 @@ func TestMessageSignVerify(t *testing.T) { message := "test message" // Create the key. - generate := runEthkey(t, "generate", keyfile) + generate := runEthkey(t, "generate", "--lightkdf", keyfile) generate.Expect(` !! Unsupported terminal, password will be echoed. Password: {{.InputLine "foobar"}}