Java ECDSASigner.verifySignature方法代码示例(javaecdsasigner.verifysignature方法的典型用法代码示例)

本文整理汇总了Java中org.bouncycastle.crypto.signers.ECDSASigner.verifySignature方法的典型用法代码示例。如果您正苦于以下问题:Java ECDSASigner.verifySignature方法的具体用法?Java ECDSASigner.verifySignature怎么用?Java ECDSASigner.verifySignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.signers.ECDSASigner的用法示例。


Java ECDSASigner.verifySignature方法代码示例(javaecdsasigner.verifysignature方法的典型用法代码示例)

在下文中一共展示了ECDSASigner.verifySignature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: verify

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
@Override
public boolean verify(byte[] hash, byte[] signature, byte[] publicKey) {
    ASN1InputStream asn1 = new ASN1InputStream(signature);
    try {
        ECDSASigner signer = new ECDSASigner();
        signer.init(false, new ECPublicKeyParameters(curve.getCurve().decodePoint(publicKey), domain));

        DLSequence seq = (DLSequence) asn1.readObject();
        BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();
        BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();
        return signer.verifySignature(hash, r, s);
    } catch (Exception e) {
        return false;
    } finally {
        try {
            asn1.close();
        } catch (IOException ignored) {
        }
    }
} 
开发者ID:hyperledger-archives,项目名称:fabric-api-archive,代码行数:21,代码来源:BouncyCastleCrypto.java

示例2: verifySignature

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
public static boolean verifySignature(byte[] sigR, byte sigS[], byte[] publicKey, byte[] message) {
  try {
    Security.addProvider(new BouncyCastleProvider());
    ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec(SECP256K1);
    ECDomainParameters domain = new ECDomainParameters(spec.getCurve(), spec.getG(), spec.getN());
    ECPublicKeyParameters publicKeyParams =
        new ECPublicKeyParameters(spec.getCurve().decodePoint(publicKey), domain);

    ECDSASigner signer = new ECDSASigner();
    signer.init(false, publicKeyParams);
    return signer.verifySignature(message, new BigInteger(1, sigR), new BigInteger(1, sigS));
  } catch (Exception e) {
    LOGGER.error(null, e);
    return false;
  }
} 
开发者ID:Braveno,项目名称:cosigner,代码行数:17,代码来源:Secp256k1.java

示例3: verifyUsingSecp256k1

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
public static boolean verifyUsingSecp256k1(byte[] pub, byte[] dataForSigning,
		BigInteger[] rs) throws Exception {
	ECDSASigner signer = new ECDSASigner();
	X9ECParameters params = SECNamedCurves.getByName("secp256k1");
	ECDomainParameters ecParams = new ECDomainParameters(params.getCurve(),
			params.getG(), params.getN(), params.getH());
	ECPublicKeyParameters pubKeyParams = new ECPublicKeyParameters(ecParams
			.getCurve().decodePoint(pub), ecParams);
	signer.init(false, pubKeyParams);

	return signer.verifySignature(dataForSigning, rs[0].abs(), rs[1].abs());
} 
开发者ID:eBay,项目名称:UAF,代码行数:13,代码来源:NamedCurve.java

示例4: isSignatureVerified

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
public boolean isSignatureVerified(StellarBinaryObject serObj) {
	try {
		byte[] signatureBytes= (byte[]) serObj.getField(BinaryFormatField.TxnSignature);
		if(signatureBytes==null){
			throw new RuntimeException("The specified  has no signature");
		}
		byte[] signingPubKeyBytes = (byte[]) serObj.getField(BinaryFormatField.SigningPubKey);
		if(signingPubKeyBytes==null){
			throw new RuntimeException("The specified  has no public key associated to the signature");
		}

		StellarBinaryObject unsignedRBO = serObj.getUnsignedCopy();
		byte[] hashToVerify = unsignedRBO.generateHashFromBinaryObject();

		ECDSASigner signer = new ECDSASigner();
		ECDSASignature signature = new ECDSASignature(signatureBytes, signingPubKeyBytes);
		signer.init(false, new ECPublicKeyParameters(signature.publicSigningKey, StellarDeterministicKeyGenerator.SECP256K1_PARAMS));
		return signer.verifySignature(hashToVerify, signature.r, signature.s);
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
} 
开发者ID:pmarches,项目名称:jStellarAPI,代码行数:23,代码来源:StellarSigner.java

示例5: testECDSAKeyGenTest

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
/**
 * key generation test
 */
private void testECDSAKeyGenTest()
{
    SecureRandom    random = new SecureRandom();
    ECCurve.Fp curve = new ECCurve.Fp(
        new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
        new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
        new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b

    ECDomainParameters params = new ECDomainParameters(
        curve,
        curve.decodePoint(Hex.decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
        new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // 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");
    }
} 
开发者ID:credentials,项目名称:irma_future_id,代码行数:43,代码来源:ECTest.java

示例6: verify

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
public static boolean verify(byte[] pub, byte[] dataForSigning,
		BigInteger[] rs) throws Exception {
	ECDSASigner signer = new ECDSASigner();
	X9ECParameters params = SECNamedCurves.getByName("secp256r1");
	ECDomainParameters ecParams = new ECDomainParameters(params.getCurve(),
			params.getG(), params.getN(), params.getH());
	ECPublicKeyParameters pubKeyParams = new ECPublicKeyParameters(ecParams
			.getCurve().decodePoint(pub), ecParams);
	signer.init(false, pubKeyParams);

	return signer.verifySignature(dataForSigning, rs[0].abs(), rs[1].abs());
} 
开发者ID:zsavvas,项目名称:ReCRED_FIDO_UAF_OIDC,代码行数:13,代码来源:NamedCurve.java

示例7: verifySignature

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
public boolean verifySignature(byte[] message, BigInteger r, BigInteger s) {
    ECDomainParameters ecDomainParameters = ECAssistant.ecDomainParametersFrom(x9ECParameters);
    ECPublicKeyParameters ecPublicKeyParameters = new ECPublicKeyParameters(Q, ecDomainParameters);

    ECDSASigner signer = new ECDSASigner();
    signer.init(false, ecPublicKeyParameters);

    return signer.verifySignature(message, r, s);
} 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:10,代码来源:ECCurvePoint.java

示例8: verify

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
public boolean verify(byte[] message, byte[] signature) throws Exception
{
    ASN1InputStream asn1 = new ASN1InputStream(signature);
    ECDSASigner signer = new ECDSASigner();
    //not for signing...
    signer.init(false, new ECPublicKeyParameters(curve.getCurve().decodePoint(pub), params));
    DLSequence seq = (DLSequence) asn1.readObject();
    BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();
    BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();
    return signer.verifySignature(message, r, s);
} 
开发者ID:bushidowallet,项目名称:bushido-java-core,代码行数:12,代码来源:ECKey.java

示例9: verifySignature

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
/**
 * Verifies a signature for the signed contents using the public key
 *
 * @param       contents            The signed contents
 * @param       signature           DER-encoded signature
 * @return                          TRUE if the signature if valid, FALSE otherwise
 * @throws      ECException         Unable to verify the signature
 */
public boolean verifySignature(byte[] contents, byte[] signature) throws ECException {
    boolean isValid = false;
    //
    // Decode the DER-encoded signature and get the R and S values
    //
    ECDSASignature sig = new ECDSASignature(signature);
    //
    // Get the double SHA-256 hash of the signed contents
    //
    // A null contents will result in a hash with the first byte set to 1 and
    // all other bytes set to 0.  This is needed to handle a bug in the reference
    // client where it doesn't check for an error when serializing a transaction
    // and instead uses the error code as the hash.
    //
    byte[] contentsHash;
    if (contents != null) {
        contentsHash = Utils.doubleDigest(contents);
    } else {
        contentsHash = new byte[32];
        contentsHash[0] = 0x01;
    }
    //
    // Verify the signature
    //
    try {
        ECDSASigner signer = new ECDSASigner();
        ECPublicKeyParameters params = new ECPublicKeyParameters(
                                            ecParams.getCurve().decodePoint(pubKey), ecParams);
        signer.init(false, params);
        isValid = signer.verifySignature(contentsHash, sig.getR(), sig.getS());
    } catch (RuntimeException exc) {
        throw new ECException("Exception while verifying signature: "+exc.getMessage());
    }
    return isValid;
} 
开发者ID:ScripterRon,项目名称:BitcoinCore,代码行数:44,代码来源:ECKey.java

示例10: testECDSA192bitPrime

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
/**
 * 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");
    }
} 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:66,代码来源:ECTest.java

示例11: testECDSA239bitPrime

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
/**
 * 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");
    }
} 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:65,代码来源:ECTest.java

示例12: testECDSA191bitBinary

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
/**
 * X9.62 - 1998,<br>
 * J.2.1, Page 100, ECDSA over the field F2m<br>
 * an example with 191 bit binary field
 */
private void testECDSA191bitBinary()
{
    BigInteger r = new BigInteger("87194383164871543355722284926904419997237591535066528048");
    BigInteger s = new BigInteger("308992691965804947361541664549085895292153777025772063598");

    byte[] kData = BigIntegers.asUnsignedByteArray(new BigInteger("1542725565216523985789236956265265265235675811949404040041"));
    
    SecureRandom k = new FixedSecureRandom(kData);

    BigInteger n = new BigInteger("1569275433846670190958947355803350458831205595451630533029");
    BigInteger h = BigInteger.valueOf(2);

    ECCurve.F2m curve = new ECCurve.F2m(
        191, // m
        9, //k
        new BigInteger("2866537B676752636A68F56554E12640276B649EF7526267", 16), // a
        new BigInteger("2E45EF571F00786F67B0081B9495A3D95462F5DE0AA185EC", 16), // b
        n, h);

    ECDomainParameters params = new ECDomainParameters(
        curve,
        curve.decodePoint(Hex.decode("0436B3DAF8A23206F9C4F299D7B21A9C369137F2C84AE1AA0D765BE73433B3F95E332932E70EA245CA2418EA0EF98018FB")), // G
        n, h);

    ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
        new BigInteger("1275552191113212300012030439187146164646146646466749494799"), // 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("045DE37E756BD55D72E3768CB396FFEB962614DEA4CE28A2E755C0E0E02F5FB132CAF416EF85B229BBB8E1352003125BA1")), // Q
        params);

    ecdsa.init(false, pubKey);
    if (!ecdsa.verifySignature(message, sig[0], sig[1]))
    {
        fail("signature fails");
    }
} 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:67,代码来源:ECTest.java

示例13: testECDSA239bitBinary

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
/**
 * X9.62 - 1998,<br>
 * J.2.1, Page 100, ECDSA over the field F2m<br>
 * an example with 191 bit binary field
 */
private void testECDSA239bitBinary()
{
    BigInteger r = new BigInteger("21596333210419611985018340039034612628818151486841789642455876922391552");
    BigInteger s = new BigInteger("197030374000731686738334997654997227052849804072198819102649413465737174");

    byte[] kData = BigIntegers.asUnsignedByteArray(new BigInteger("171278725565216523967285789236956265265265235675811949404040041670216363"));
    
    SecureRandom k = new FixedSecureRandom(kData);

    BigInteger n = new BigInteger("220855883097298041197912187592864814557886993776713230936715041207411783");
    BigInteger h = BigInteger.valueOf(4);

    ECCurve.F2m curve = new ECCurve.F2m(
        239, // m
        36, //k
        new BigInteger("32010857077C5431123A46B808906756F543423E8D27877578125778AC76", 16), // a
        new BigInteger("790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16", 16), // b
        n, h);

    ECDomainParameters params = new ECDomainParameters(
        curve,
        curve.decodePoint(Hex.decode("0457927098FA932E7C0A96D3FD5B706EF7E5F5C156E16B7E7C86038552E91D61D8EE5077C33FECF6F1A16B268DE469C3C7744EA9A971649FC7A9616305")), // G
        n, h);

    ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
        new BigInteger("145642755521911534651321230007534120304391871461646461466464667494947990"), // 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("045894609CCECF9A92533F630DE713A958E96C97CCB8F5ABB5A688A238DEED6DC2D9D0C94EBFB7D526BA6A61764175B99CB6011E2047F9F067293F57F5")), // Q
        params);

    ecdsa.init(false, pubKey);
    if (!ecdsa.verifySignature(message, sig[0], sig[1]))
    {
        fail("signature fails");
    }
} 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:67,代码来源:ECTest.java

示例14: testECDSAP224sha224

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
private void testECDSAP224sha224()
{
    X9ECParameters p = NISTNamedCurves.getByName("P-224");
    ECDomainParameters params = new ECDomainParameters(p.getCurve(), p.getG(), p.getN(), p.getH());
    ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
        new BigInteger("6081831502424510080126737029209236539191290354021104541805484120491"), // d
        params);
    SecureRandom    k = new FixedSecureRandom(BigIntegers.asUnsignedByteArray(new BigInteger("15456715103636396133226117016818339719732885723579037388121116732601")));
    
    byte[] M = Hex.decode("8797A3C693CC292441039A4E6BAB7387F3B4F2A63D00ED384B378C79");

    ECDSASigner dsa = new ECDSASigner();

    dsa.init(true, new ParametersWithRandom(priKey, k));

    BigInteger[] sig = dsa.generateSignature(M);

    BigInteger r = new BigInteger("26477406756127720855365980332052585411804331993436302005017227573742");
    BigInteger s = new BigInteger("17694958233103667059888193972742186995283044672015112738919822429978");
    
    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(
        params.getCurve().decodePoint(Hex.decode("03FD44EC11F9D43D9D23B1E1D1C9ED6519B40ECF0C79F48CF476CC43F1")), // Q
        params);

    dsa.init(false, pubKey);
    if (!dsa.verifySignature(M, sig[0], sig[1]))
    {
        fail("signature fails");
    }
} 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:46,代码来源:ECTest.java

示例15: testECDSASecP224k1sha256

import org.bouncycastle.crypto.signers.ECDSASigner; //导入方法依赖的package包/类
private void testECDSASecP224k1sha256()
{
    X9ECParameters p = SECNamedCurves.getByName("secp224k1");
    ECDomainParameters params = new ECDomainParameters(p.getCurve(), p.getG(), p.getN(), p.getH());
    ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
        new BigInteger("BE6F6E91FE96840A6518B56F3FE21689903A64FA729057AB872A9F51", 16), // d
        params);
    SecureRandom    k = new FixedSecureRandom(Hex.decode("00c39beac93db21c3266084429eb9b846b787c094f23a4de66447efbb3"));
   
    byte[] M = Hex.decode("E5D5A7ADF73C5476FAEE93A2C76CE94DC0557DB04CDC189504779117920B896D");

    ECDSASigner dsa = new ECDSASigner();

    dsa.init(true, new ParametersWithRandom(priKey, k));

    BigInteger[] sig = dsa.generateSignature(M);

    BigInteger r = new BigInteger("8163E5941BED41DA441B33E653C632A55A110893133351E20CE7CB75", 16);
    BigInteger s = new BigInteger("D12C3FC289DDD5F6890DCE26B65792C8C50E68BF551D617D47DF15A8", 16);

    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(
        params.getCurve().decodePoint(Hex.decode("04C5C9B38D3603FCCD6994CBB9594E152B658721E483669BB42728520F484B537647EC816E58A8284D3B89DFEDB173AFDC214ECA95A836FA7C")), // Q
        params);

    dsa.init(false, pubKey);
    if (!dsa.verifySignature(M, sig[0], sig[1]))
    {
        fail("signature fails");
    }
} 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:46,代码来源:ECTest.java

本文标签属性:

示例:示例的拼音

代码:代码生成器

java:java面试题

ECDSASigner:ECDSASigner

verifySignature:verifySignature

上一篇:庐山的拼音(庐山的简介是什么)(庐山的简介是什么?)
下一篇:Java SchedulerFactoryBean类代码示例(javaschedulerfactorybean类的典型用法代码示例)

为您推荐