/** * Generates an option instance containing suitable options and description. * * @return Option instance representing valid inputs to this instance. */ protected Opt opt() { Opt opt = GeneratorTool.defaultOpt(SignaturePKey.class.getSimpleName(), 1); opt.setUsageComment( "(where " + SignaturePKey.class.getSimpleName() + " = " + SignaturePKey.class.getName() + ")"); opt.addParameter("keypair", "Signature key pair " + "(vfork.crypto.SignatureKeyPair)."); opt.addOption( "-cert", "value", "Determines the probability that the input key pair " + "is malformed, i.e., a value " + "of t gives a bound of 2^(-t)." + " Defaults to " + DEFAULT_CERT + "."); String s = "Extracts a signature public key from a key pair."; opt.appendToUsageForm(1, "#-cert#keypair#"); opt.appendDescription(s); return opt; }
public String gen(RandomSource randomSource, String[] args) throws GenException { Opt opt = opt(); String res = GeneratorTool.defaultProcess(opt, args); if (res != null) { return res; } String keypairString = opt.getStringValue("keypair"); int certainty = opt.getIntValue("-cert", DEFAULT_CERT); try { SignatureKeyPair keypair = Marshalizer.unmarshalHexAux_SignatureKeyPair(keypairString, randomSource, certainty); return Marshalizer.marshalToHexHuman(keypair.getPKey(), opt.getBooleanValue("-v")); } catch (EIOException eioe) { throw new GenException("Malformed key pair!", eioe); } }