示例#1
0
	bool prove(const string& fname) {
		BOOST_TEST_MESSAGE( "## Running proof test for " << fname );

		startTimer();
		prover.check(ZKP_DIR + fname); // throws compilation errs
		printTimer("prover.check");

		startTimer();
		prover.compute(env.groups, env.variables);
		printTimer("prover.compute");

		startTimer();
		SigmaProof proof = prover.computeProof();
		printTimer("prover.computeProof");
		
		verifier.check(ZKP_DIR + fname);
		// need to get the right inputs for verifier
		variable_map publics = prover.getPublicVariables();

		startTimer();
		verifier.compute(env.groups, publics);
		printTimer("verifier.compute");

		startTimer();
		bool ok = verifier.verifyProof(proof);
		printTimer("verifier.verifyProof");

		return ok;
	}
示例#2
0
bool BankTool::verifyIdentity(ProofMessage* idProof, const ZZ &userPK) const {
	// check user's PoK of sk_u such that pk_u = g^sk_u
	InterpreterVerifier verifier;
	group_map g;
	g["G"] = bankParameters->getCashGroup();
	verifier.check(CommonFunctions::getZKPDir()+"/userid.txt", input_map(), g);
	variable_map v;
	v["pk_u"] = userPK;
	verifier.compute(v, idProof->publics);
	return verifier.verify(idProof->proof, stat);
}
示例#3
0
bool CLBlindRecipient::verifySig(const ProofMessage &pm, int stat){
	startTimer();
	InterpreterVerifier verifier;
    verifier.check("ZKP/examples/cl-issue.txt", inputs);
	// XXX: does the verifier really not need any inputs of its own?
	// this would be a good place to incorporate public messages...
	variable_map q;
	variable_map pubs = pm.publics;
    verifier.compute(q, pubs, g);
	
	bool verified = verifier.verify(pm.proof, stat);
	printTimer("[CLBlindRecipient] verified issuer proof");
	return verified;
}
示例#4
0
bool VEVerifier::verify(const VECiphertext& text, const ZZ& x, 
                        const Group *grp, const string& label, 
                        const hashalg_t& hashAlg, int stat) {
	// set everything up (a lot like the prover side)
	Environment env;
	env.variables["X"] = x;
	env.variables["Xprime"] = text.getCommitment();
	// also add a values
	vector<ZZ> as = pk->getAValues();
	for (unsigned i = 0; i < as.size(); i++) {
		string name = "a_" + lexical_cast<string>(i+1);
		env.variables[name] = as[i];
	}
	env.variables["b"] = pk->getB();
	env.variables["d"] = pk->getD();
	env.variables["e"] = pk->getE();
	env.variables["f"] = pk->getF();

	// set up all groups
	env.groups["cashGroup"] = grp;
	ZZ bigN = pk->getN();
	env.groups["RSAGroup"] = new GroupRSA("arbiter", bigN, stat);
	ZZ bigNSquared = power(bigN, 2);
	env.groups["G"] = new GroupSquareMod("arbiter", bigNSquared, stat);
	const GroupRSA* second = new GroupRSA(pk->getSecondGroup());
	env.groups["secondGroup"] = second;
	input_map inputs;
	inputs["m"] = text.getCiphertext().size() - 2;

	// okay, now that everything is all set, just run the program
	SigmaProof proof = text.getProof();
	variable_map publics = text.getPublics();
	InterpreterVerifier verifier;
	verifier.check("ZKP/examples/ve.txt", inputs, env.groups);
	verifier.compute(env.variables, proof.getCommitments(), publics);
	return verifier.verify(proof, stat);
}