diff --git a/src/auth.py b/src/auth.py index c1a9dc745d1227920615d3aab727d77c9240b8b0..a557799f18f09f56129c030057a2219fbf1edd64 100644 --- a/src/auth.py +++ b/src/auth.py @@ -10,7 +10,7 @@ import os def auth_method(c): if c.contains_switches('auth-scrypt'): - return auth_by_scrypt() + return auth_by_scrypt(c) if c.contains_switches('auth-seed'): return auth_by_seed() if c.contains_switches('auth-file'): @@ -59,19 +59,24 @@ def auth_by_seed(): return seed -def auth_by_scrypt(): +def auth_by_scrypt(c): salt = input("Please enter your Scrypt Salt (Secret identifier): ") password = getpass.getpass("Please enter your Scrypt password (masked): ") - scrypt_param = input("Please enter your Scrypt parameters (N,r,p):" + - "default [4096,16,1]: ") - if not scrypt_param: - scrypt_param = "4096,16,1" - scrypt_param_splited = scrypt_param.split(",") - n = int(scrypt_param_splited[0]) - r = int(scrypt_param_splited[1]) - p = int(scrypt_param_splited[2]) - if (n <= 0 or n > 65536 or r <= 0 or r > 512 or p <= 0 or p > 32): - print("Error: the values of Scrypt parameters are not good") + + if c.contains_definitions('n') and c.contains_definitions('r') and c.contains_definitions('p'): + n, r, p = c.get_definition('n'), c.get_definition('r'), c.get_definition('p') + if n.isnumeric() and r.isnumeric() and p.isnumeric(): + n, r, p = int(n), int(r), int(p) + if n <= 0 or n > 65536 or r <= 0 or r > 512 or p <= 0 or p > 32: + print("Error: the values of Scrypt parameters are not good") + exit(1) + else: + print("one of n, r or p is not a number") + exit(1) + else: + print("Using default values. Scrypt parameters not specified or wrong format") + n, r, p = 4096, 16, 1 + print("Scrypt parameters used: N: {0}, r: {1}, p: {2}".format(n, r, p)) return get_seed_from_scrypt(salt, password, n, r, p) diff --git a/src/silkaj.py b/src/silkaj.py index 4e6f0f9a5beec1f2832177d800ce865ef7f710fd..637e382272c937054aeaa398dc45c040dbb5a938 100755 --- a/src/silkaj.py +++ b/src/silkaj.py @@ -18,15 +18,19 @@ def usage(): \n - info: Display information about currency \ \n \ \n - amount: Get amount of one account \ - \n --pubkey=<pubkey[:checksum]> | --auth-scrypt\ - \n --auth-seed | --auth-file | --auth-wif\ + \n --pubkey=<pubkey[:checksum]>\ + \n --auth-scrypt [script parameters -n <N> -r <r> -p <p>] (default: 4096,16,1)\ + \n --auth-seed | --auth-file [--file=<path file>] | --auth-wif\ \n \ \n - transaction: Send transaction\ - \n --auth-scrypt | --auth-seed | --auth-file [--file=<path file>] | --auth-wif\ - \n --amountDU=<relative value> | --amount=<quantitative value>\ + \n - authentication:\ + \n --auth-scrypt [script parameters -n <N> -r <r> -p <p>] (default: 4096,16,1)\ + \n --auth-seed | --auth-file [--file=<path file>] | --auth-wif\ + \n - amount:\ + \n --amountDU=<relative value> | --amount=<quantitative value>\ + \n [--allSources] \ \n --output=<public key>[:checksum] \ \n [--comment=<comment>] \ - \n [--allSources] \ \n [--outputBackChange=<public key[:checksum]>] \ \n [-y | --yes], don't ask for prompt confirmation \ \n \ @@ -44,8 +48,8 @@ def usage(): \n - argos: display currency information formated for Argos or BitBar\ \n \ \n - generate_auth_file: Generate file to store the seed of the account\ - \n --auth-scrypt | --auth-seed | --auth-wif\ - \n [--file=<path file>] \ + \n --auth-scrypt [script parameters -n <N> -r <r> -p <p>] (default: 4096,16,1)\ + \n --auth-seed | --auth-file [--file=<path file>] | --auth-wif\ \n \ \n - id <pubkey> or <identity>: get corresponding identity or pubkey from pubkey or identity.\ \n it could autocomplete the pubkey corresponding to an identity with three or four following characters.")