Allow specifying elliptic curve name when generating keys on mixer command-line

android-scanner
Tal Moran 2017-02-01 21:34:18 +02:00
parent b360ae81bb
commit 181f49145f
2 changed files with 11 additions and 5 deletions

View File

@ -33,7 +33,7 @@ import static java.lang.System.exit;
* Command-line mixProverVerifier and verifier.
*/
public class Mix {
final static String DEFAULT_ECGROUP = "secp256k1";
final static String DEFAULT_ECGROUP = "secp256r1";
final static Logger logger = LoggerFactory.getLogger(Mix.class);
public Random rand;
@ -108,13 +108,17 @@ public class Mix {
mixProverVerifier = new Mix2nizk(rand, enc);
}
public void createKeypair(File outFile) throws IOException {
createKeypair(DEFAULT_ECGROUP, outFile);
}
/**
* Create a new ECElGamal key pair and write it serialized to file.
*
* @param outFile
*/
public void createKeypair(File outFile) throws IOException {
group = new ECGroup(DEFAULT_ECGROUP);
public void createKeypair(String curveName, File outFile) throws IOException {
group = new ECGroup(curveName);
BigInteger sk = ECElGamal.generateSecretKey(group, rand);
secretKey = new ECElGamal.SK(group, sk);
@ -228,6 +232,8 @@ public class Mix {
public static void main(String[] args) {
OptionParser parser = new OptionParser();
final OptionSpec<Void> OPT_HELP = parser.accepts("help", "Print help");
final OptionSpec<String> OPT_CURVENAME = parser.accepts("curve-name", "Use the given named elliptic curve").withRequiredArg().ofType(String.class)
.defaultsTo(DEFAULT_ECGROUP);
final OptionSpec<Void> OPT_GENKEY = parser.accepts("genkey", "Generate a key-pair (write into key file)");
final OptionSpec<Void> OPT_DECRYPT = parser.accepts("decrypt", "Decrypt using given keypair");
final OptionSpec<File> OPT_KEYFILE = parser.accepts("keys", "File containing public key (or keypair for decryption)").withRequiredArg().ofType(File.class);
@ -261,7 +267,7 @@ public class Mix {
try {
if (options.has(OPT_GENKEY)) {
mix.createKeypair(keyFile);
mix.createKeypair(options.valueOf(OPT_CURVENAME), keyFile);
} else {
mix.loadKeypair(keyFile);
if (options.has(OPT_ENCRYPT)) {

View File

@ -28,7 +28,7 @@ public class SigmaFiatShamir<NIZKMsgType, FirstMsgType extends Message, FinalMes
}
/**
* FiatShamir heuristic
* Fiat-Shamir heuristic
* @param input - protobuf contains all parameters from the first step of the current proof
* @return randomOracle.hash(input)
*/