本文整理汇总了Java中org.bouncycastle.math.ec.ECConstants.ONE属性的典型用法代码示例。如果您正苦于以下问题:Java ECConstants.ONE属性的具体用法?Java ECConstants.ONE怎么用?Java ECConstants.ONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bouncycastle.math.ec.ECConstants
的用法示例。
在下文中一共展示了ECConstants.ONE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performTest
public void performTest()
throws Exception
{
BigInteger n = new BigInteger("6277101735386680763835789423176059013767194773182842284081");
ECCurve.Fp curve = new ECCurve.Fp(
new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16), // b
n, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.decodePoint(Hex.decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G
n);
ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
curve.decodePoint(Hex.decode("0262b12d60690cdcf330babab6e69763b471f994dd702d16a5")), // Q
params);
ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
params);
ParametersWithRandom pRandom = new ParametersWithRandom(pubKey, new SecureRandom());
doTest(priKey, pRandom, BigInteger.valueOf(20));
BigInteger rand = new BigInteger(pubKey.getParameters().getN().bitLength() - 1, new SecureRandom());
doTest(priKey, pRandom, rand);
}
示例2: performTest
public void performTest()
throws Exception
{
BigInteger n = new BigInteger("6277101735386680763835789423176059013767194773182842284081");
ECCurve.Fp curve = new ECCurve.Fp(
new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16), // b
n, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.decodePoint(Hex.decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G
n);
ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
curve.decodePoint(Hex.decode("0262b12d60690cdcf330babab6e69763b471f994dd702d16a5")), // Q
params);
ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
params);
ParametersWithRandom pRandom = new ParametersWithRandom(pubKey, new SecureRandom());
doTest(priKey, pRandom, BigInteger.valueOf(20));
BigInteger rand = new BigInteger(pubKey.getParameters().getN().bitLength() - 1, new SecureRandom());
doTest(priKey, pRandom, rand);
doSameKeyTest(priKey, pRandom, rand);
}
示例3: testECMQVRandom
private void testECMQVRandom()
{
SecureRandom random = new SecureRandom();
BigInteger n = new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307");
ECCurve.Fp curve = new ECCurve.Fp(
new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16), // b
n, ECConstants.ONE);
ECDomainParameters parameters = new ECDomainParameters(
curve,
curve.decodePoint(Hex.decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
n);
ECKeyPairGenerator pGen = new ECKeyPairGenerator();
pGen.init(new ECKeyGenerationParameters(parameters, random));
// Pre-established key pairs
AsymmetricCipherKeyPair U1 = pGen.generateKeyPair();
AsymmetricCipherKeyPair V1 = pGen.generateKeyPair();
// Ephemeral key pairs
AsymmetricCipherKeyPair U2 = pGen.generateKeyPair();
AsymmetricCipherKeyPair V2 = pGen.generateKeyPair();
BigInteger x = calculateAgreement(U1, U2, V1, V2);
if (x == null)
{
fail("MQV Test Vector (random) agreement failed");
}
}
示例4: performTest
public void performTest()
throws Exception
{
doStaticTest(null);
doStaticTest(TWOFISH_IV);
doShortTest(null);
BigInteger n = new BigInteger("6277101735386680763835789423176059013767194773182842284081");
ECCurve.Fp curve = new ECCurve.Fp(
new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16), // b
n, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.decodePoint(Hex.decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G
n);
ECKeyPairGenerator eGen = new ECKeyPairGenerator();
KeyGenerationParameters gParam = new ECKeyGenerationParameters(params, new SecureRandom());
eGen.init(gParam);
AsymmetricCipherKeyPair p1 = eGen.generateKeyPair();
AsymmetricCipherKeyPair p2 = eGen.generateKeyPair();
doTest(p1, p2);
doEphemeralTest(null, false);
doEphemeralTest(null, true);
doEphemeralTest(TWOFISH_IV, false);
doEphemeralTest(TWOFISH_IV, true);
}
示例5: extEuclidGLV
private static BigInteger[] extEuclidGLV(BigInteger n, BigInteger lambda)
{
BigInteger r0 = n, r1 = lambda;
// BigInteger s0 = ECConstants.ONE, s1 = ECConstants.ZERO;
BigInteger t0 = ECConstants.ZERO, t1 = ECConstants.ONE;
for (;;)
{
BigInteger[] qr = r0.divideAndRemainder(r1);
BigInteger q = qr[0], r2 = qr[1];
// BigInteger s2 = s0.subtract(q.multiply(s1));
BigInteger t2 = t0.subtract(q.multiply(t1));
if (isLessThanSqrt(r1, n))
{
return new BigInteger[]{ r0, t0, r1, t1, r2, t2 };
}
r0 = r1;
r1 = r2;
// s0 = s1;
// s1 = s2;
t0 = t1;
t1 = t2;
}
}
示例6: extEuclidBezout
private static BigInteger[] extEuclidBezout(BigInteger[] ab)
{
boolean swap = ab[0].compareTo(ab[1]) < 0;
if (swap)
{
swap(ab);
}
BigInteger r0 = ab[0], r1 = ab[1];
BigInteger s0 = ECConstants.ONE, s1 = ECConstants.ZERO;
BigInteger t0 = ECConstants.ZERO, t1 = ECConstants.ONE;
while (r1.compareTo(ECConstants.ONE) > 0)
{
BigInteger[] qr = r0.divideAndRemainder(r1);
BigInteger q = qr[0], r2 = qr[1];
BigInteger s2 = s0.subtract(q.multiply(s1));
BigInteger t2 = t0.subtract(q.multiply(t1));
r0 = r1;
r1 = r2;
s0 = s1;
s1 = s2;
t0 = t1;
t1 = t2;
}
if (r1.signum() <= 0)
{
throw new IllegalStateException();
}
BigInteger[] st = new BigInteger[]{ s1, t1 };
if (swap)
{
swap(st);
}
return st;
}
示例7: testECDSA192bitPrime
/**
* X9.62 - 1998,<br>
* J.3.1, Page 152, ECDSA over the field Fp<br>
* an example with 192 bit prime
*/
private void testECDSA192bitPrime()
{
BigInteger r = new BigInteger("3342403536405981729393488334694600415596881826869351677613");
BigInteger s = new BigInteger("5735822328888155254683894997897571951568553642892029982342");
byte[] kData = BigIntegers.asUnsignedByteArray(new BigInteger("6140507067065001063065065565667405560006161556565665656654"));
SecureRandom k = new FixedSecureRandom(kData);
BigInteger n = new BigInteger("6277101735386680763835789423176059013767194773182842284081");
ECCurve.Fp curve = new ECCurve.Fp(
new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16), // b
n, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.decodePoint(Hex.decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G
n);
ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
params);
ParametersWithRandom param = new ParametersWithRandom(priKey, k);
ECDSASigner ecdsa = new ECDSASigner();
ecdsa.init(true, param);
byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").toByteArray();
BigInteger[] sig = ecdsa.generateSignature(message);
if (!r.equals(sig[0]))
{
fail("r component wrong." + Strings.lineSeparator()
+ " expecting: " + r + Strings.lineSeparator()
+ " got : " + sig[0]);
}
if (!s.equals(sig[1]))
{
fail("s component wrong." + Strings.lineSeparator()
+ " expecting: " + s + Strings.lineSeparator()
+ " got : " + sig[1]);
}
// Verify the signature
ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
curve.decodePoint(Hex.decode("0262b12d60690cdcf330babab6e69763b471f994dd702d16a5")), // Q
params);
ecdsa.init(false, pubKey);
if (!ecdsa.verifySignature(message, sig[0], sig[1]))
{
fail("verification fails");
}
}
示例8: testECDSA239bitPrime
/**
* X9.62 - 1998,<br>
* J.3.2, Page 155, ECDSA over the field Fp<br>
* an example with 239 bit prime
*/
private void testECDSA239bitPrime()
{
BigInteger r = new BigInteger("308636143175167811492622547300668018854959378758531778147462058306432176");
BigInteger s = new BigInteger("323813553209797357708078776831250505931891051755007842781978505179448783");
byte[] kData = BigIntegers.asUnsignedByteArray(new BigInteger("700000017569056646655505781757157107570501575775705779575555657156756655"));
SecureRandom k = new FixedSecureRandom(true, kData);
BigInteger n = new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307");
ECCurve.Fp curve = new ECCurve.Fp(
new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16), // b
n, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.decodePoint(Hex.decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
n);
ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
new BigInteger("876300101507107567501066130761671078357010671067781776716671676178726717"), // d
params);
ECDSASigner ecdsa = new ECDSASigner();
ParametersWithRandom param = new ParametersWithRandom(priKey, k);
ecdsa.init(true, param);
byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").toByteArray();
BigInteger[] sig = ecdsa.generateSignature(message);
if (!r.equals(sig[0]))
{
fail("r component wrong." + Strings.lineSeparator()
+ " expecting: " + r + Strings.lineSeparator()
+ " got : " + sig[0]);
}
if (!s.equals(sig[1]))
{
fail("s component wrong." + Strings.lineSeparator()
+ " expecting: " + s + Strings.lineSeparator()
+ " got : " + sig[1]);
}
// Verify the signature
ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
curve.decodePoint(Hex.decode("025b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c70")), // Q
params);
ecdsa.init(false, pubKey);
if (!ecdsa.verifySignature(message, sig[0], sig[1]))
{
fail("signature fails");
}
}
示例9: testECDSAKeyGenTest
/**
* key generation test
*/
private void testECDSAKeyGenTest()
{
SecureRandom random = new SecureRandom();
BigInteger n = new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307");
ECCurve.Fp curve = new ECCurve.Fp(
new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16), // b
n, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.decodePoint(Hex.decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
n);
ECKeyPairGenerator pGen = new ECKeyPairGenerator();
ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(
params,
random);
pGen.init(genParam);
AsymmetricCipherKeyPair pair = pGen.generateKeyPair();
ParametersWithRandom param = new ParametersWithRandom(pair.getPrivate(), random);
ECDSASigner ecdsa = new ECDSASigner();
ecdsa.init(true, param);
byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").toByteArray();
BigInteger[] sig = ecdsa.generateSignature(message);
ecdsa.init(false, pair.getPublic());
if (!ecdsa.verifySignature(message, sig[0], sig[1]))
{
fail("signature fails");
}
}
示例10: ecGOST3410_TEST
private void ecGOST3410_TEST()
{
BigInteger mod_p = new BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564821041"); //p
BigInteger mod_q = new BigInteger("57896044618658097711785492504343953927082934583725450622380973592137631069619");
ECCurve.Fp curve = new ECCurve.Fp(
mod_p, // p
new BigInteger("7"), // a
new BigInteger("43308876546767276905765904595650931995942111794451039583252968842033849580414"), // b
mod_q, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.createPoint(
new BigInteger("2"), // x
new BigInteger("4018974056539037503335449422937059775635739389905545080690979365213431566280")), // y
mod_q);
ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
new BigInteger("55441196065363246126355624130324183196576709222340016572108097750006097525544"), // d
params);
ParametersWithRandom param = new ParametersWithRandom(priKey, k);
ECGOST3410Signer ecgost3410 = new ECGOST3410Signer();
ecgost3410.init(true, param);
byte[] mVal = new BigInteger("20798893674476452017134061561508270130637142515379653289952617252661468872421").toByteArray();
byte[] message = new byte[mVal.length];
for (int i = 0; i != mVal.length; i++)
{
message[i] = mVal[mVal.length - 1 - i];
}
BigInteger[] sig = ecgost3410.generateSignature(message);
if (!r.equals(sig[0]))
{
fail("r component wrong.", r, sig[0]);
}
if (!s.equals(sig[1]))
{
fail("s component wrong.", s, sig[1]);
}
// Verify the signature
ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
curve.createPoint(
new BigInteger("57520216126176808443631405023338071176630104906313632182896741342206604859403"), // x
new BigInteger("17614944419213781543809391949654080031942662045363639260709847859438286763994")), // y
params);
ecgost3410.init(false, pubKey);
if (!ecgost3410.verifySignature(message, sig[0], sig[1]))
{
fail("verification fails");
}
}
示例11: ecGOST3410_TestParam
/**
* Test Sign & Verify with test parameters
* see: http://www.ietf.org/internet-drafts/draft-popov-cryptopro-cpalgs-01.txt
* gostR3410-2001-TestParamSet P.46
*/
private void ecGOST3410_TestParam()
{
SecureRandom random = new SecureRandom();
BigInteger mod_p = new BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564821041"); //p
BigInteger mod_q = new BigInteger("57896044618658097711785492504343953927082934583725450622380973592137631069619");
ECCurve.Fp curve = new ECCurve.Fp(
mod_p, // p
new BigInteger("7"), // a
new BigInteger("43308876546767276905765904595650931995942111794451039583252968842033849580414"), // b
mod_q, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.createPoint(
new BigInteger("2"), // x
new BigInteger("4018974056539037503335449422937059775635739389905545080690979365213431566280")), // y
mod_q);
ECKeyPairGenerator pGen = new ECKeyPairGenerator();
ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(
params,
random);
pGen.init(genParam);
AsymmetricCipherKeyPair pair = pGen.generateKeyPair();
ParametersWithRandom param = new ParametersWithRandom(pair.getPrivate(), random);
ECGOST3410Signer ecgost3410 = new ECGOST3410Signer();
ecgost3410.init(true, param);
//get hash message using the digest GOST3411.
byte[] message = "Message for sign".getBytes();
GOST3411Digest gost3411 = new GOST3411Digest();
gost3411.update(message, 0, message.length);
byte[] hashmessage = new byte[gost3411.getDigestSize()];
gost3411.doFinal(hashmessage, 0);
BigInteger[] sig = ecgost3410.generateSignature(hashmessage);
ecgost3410.init(false, pair.getPublic());
if (!ecgost3410.verifySignature(hashmessage, sig[0], sig[1]))
{
fail("signature fails");
}
}
示例12: ecGOST3410_AParam
/**
* Test Sign & Verify with A parameters
* see: http://www.ietf.org/internet-drafts/draft-popov-cryptopro-cpalgs-01.txt
* gostR3410-2001-CryptoPro-A-ParamSet P.47
*/
public void ecGOST3410_AParam()
{
SecureRandom random = new SecureRandom();
BigInteger mod_p = new BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639319"); //p
BigInteger mod_q = new BigInteger("115792089237316195423570985008687907853073762908499243225378155805079068850323");
ECCurve.Fp curve = new ECCurve.Fp(
mod_p, // p
new BigInteger("115792089237316195423570985008687907853269984665640564039457584007913129639316"), // a
new BigInteger("166"), // b
mod_q, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.createPoint(
new BigInteger("1"), // x
new BigInteger("64033881142927202683649881450433473985931760268884941288852745803908878638612")), // y
mod_q);
ECKeyPairGenerator pGen = new ECKeyPairGenerator();
ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(
params,
random);
pGen.init(genParam);
AsymmetricCipherKeyPair pair = pGen.generateKeyPair();
ParametersWithRandom param = new ParametersWithRandom(pair.getPrivate(), random);
ECGOST3410Signer ecgost3410 = new ECGOST3410Signer();
ecgost3410.init(true, param);
BigInteger[] sig = ecgost3410.generateSignature(hashmessage);
ecgost3410.init(false, pair.getPublic());
if (!ecgost3410.verifySignature(hashmessage, sig[0], sig[1]))
{
fail("signature fails");
}
}
示例13: ecGOST3410_BParam
/**
* Test Sign & Verify with B parameters
* see: http://www.ietf.org/internet-drafts/draft-popov-cryptopro-cpalgs-01.txt
* gostR3410-2001-CryptoPro-B-ParamSet P.47-48
*/
private void ecGOST3410_BParam()
{
SecureRandom random = new SecureRandom();
BigInteger mod_p = new BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564823193"); //p
BigInteger mod_q = new BigInteger("57896044618658097711785492504343953927102133160255826820068844496087732066703");
ECCurve.Fp curve = new ECCurve.Fp(
mod_p, // p
new BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564823190"), // a
new BigInteger("28091019353058090096996979000309560759124368558014865957655842872397301267595"), // b
mod_q, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.createPoint(
new BigInteger("1"), // x
new BigInteger("28792665814854611296992347458380284135028636778229113005756334730996303888124")), // y
mod_q);
ECKeyPairGenerator pGen = new ECKeyPairGenerator();
ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(
params,
random);
pGen.init(genParam);
AsymmetricCipherKeyPair pair = pGen.generateKeyPair();
ParametersWithRandom param = new ParametersWithRandom(pair.getPrivate(), random);
ECGOST3410Signer ecgost3410 = new ECGOST3410Signer();
ecgost3410.init(true, param);
BigInteger[] sig = ecgost3410.generateSignature(hashmessage);
ecgost3410.init(false, pair.getPublic());
if (!ecgost3410.verifySignature(hashmessage, sig[0], sig[1]))
{
fail("signature fails");
}
}
示例14: ecGOST3410_CParam
/**
* Test Sign & Verify with C parameters
* see: http://www.ietf.org/internet-drafts/draft-popov-cryptopro-cpalgs-01.txt
* gostR3410-2001-CryptoPro-C-ParamSet P.48
*/
private void ecGOST3410_CParam()
{
SecureRandom random = new SecureRandom();
BigInteger mod_p = new BigInteger("70390085352083305199547718019018437841079516630045180471284346843705633502619"); //p
BigInteger mod_q = new BigInteger("70390085352083305199547718019018437840920882647164081035322601458352298396601");
ECCurve.Fp curve = new ECCurve.Fp(
mod_p, // p
new BigInteger("70390085352083305199547718019018437841079516630045180471284346843705633502616"), // a
new BigInteger("32858"), // b
mod_q, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.createPoint(
new BigInteger("0"), // x
new BigInteger("29818893917731240733471273240314769927240550812383695689146495261604565990247")), // y
mod_q);
ECKeyPairGenerator pGen = new ECKeyPairGenerator();
ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(
params,
random);
pGen.init(genParam);
AsymmetricCipherKeyPair pair = pGen.generateKeyPair();
ParametersWithRandom param = new ParametersWithRandom(pair.getPrivate(), random);
ECGOST3410Signer ecgost3410 = new ECGOST3410Signer();
ecgost3410.init(true, param);
BigInteger[] sig = ecgost3410.generateSignature(hashmessage);
ecgost3410.init(false, pair.getPublic());
if (!ecgost3410.verifySignature(hashmessage, sig[0], sig[1]))
{
fail("signature fails");
}
}
示例15: ecNR239bitPrime
private void ecNR239bitPrime()
{
BigInteger n = new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307");
ECCurve.Fp curve = new ECCurve.Fp(
new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16), // b
n, ECConstants.ONE);
ECDomainParameters params = new ECDomainParameters(
curve,
curve.decodePoint(Hex.decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
n);
ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
new BigInteger("876300101507107567501066130761671078357010671067781776716671676178726717"), // d
params);
ECNRSigner ecnr = new ECNRSigner();
ParametersWithRandom param = new ParametersWithRandom(priKey, k);
ecnr.init(true, param);
byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").toByteArray();
BigInteger[] sig = ecnr.generateSignature(message);
if (!r.equals(sig[0]))
{
fail("r component wrong.", r, sig[0]);
}
if (!s.equals(sig[1]))
{
fail("s component wrong.", s, sig[1]);
}
// Verify the signature
ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
curve.decodePoint(Hex.decode("025b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c70")), // Q
params);
ecnr.init(false, pubKey);
if (!ecnr.verifySignature(message, sig[0], sig[1]))
{
fail("signature fails");
}
}