コード例 #1
0
ファイル: schnorr.cpp プロジェクト: Primio/Primio
// generates new public and secret keys
void PublicKeyGen(Integer secretKey, Integer& publicKeyX, Integer& publicKeyY)
{
	Integer q;
	ECP ec;
	ECPPoint G, Q;
	LoadSECP256r1Curve(q, ec, G);

	Q = ec.ScalarMultiply(G, secretKey);
	publicKeyX = Q.x;
	publicKeyY = Q.y;
}
コード例 #2
0
ファイル: schnorr.cpp プロジェクト: Primio/Primio
void Sign(Integer& sigE, Integer& sigS, const Integer& secretKey,
	      const byte* message, int mlen, AutoSeededRandomPool& rng)
{
	Integer q,k;
	ECP ec;
	ECPPoint G, r;
	LoadSECP256r1Curve(q, ec, G);

	k = Integer(rng, 256) % q; // choose random k
	r = ec.ScalarMultiply(G, k); // r = G^k
	sigE = HashPointMessage(ec, r, message, mlen) % q; // e = H(M||r)
	sigS = (k - secretKey*sigE) % q;
}
コード例 #3
0
ファイル: schnorr.cpp プロジェクト: Primio/Primio
// generates new public and secret keys
void KeyGen(Integer& secretKey, Integer& publicKeyX, Integer& publicKeyY, AutoSeededRandomPool& rng)
{
	Integer q;
	ECP ec;
	ECPPoint G, Q;
	LoadSECP256r1Curve(q, ec, G);

	secretKey = Integer(rng, 256) % q;

	Q = ec.ScalarMultiply(G, secretKey);
	publicKeyX = Q.x;
	publicKeyY = Q.y;
}