當前位置: 首頁>>代碼示例>>Java>>正文


Java X9ECParameters類代碼示例

本文整理匯總了Java中org.spongycastle.asn1.x9.X9ECParameters的典型用法代碼示例。如果您正苦於以下問題:Java X9ECParameters類的具體用法?Java X9ECParameters怎麽用?Java X9ECParameters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


X9ECParameters類屬於org.spongycastle.asn1.x9包,在下文中一共展示了X9ECParameters類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getParameterSpec

import org.spongycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
/**
 * Retrieves the parameters of the given elliptic curve.
 * @param curveName The curve name
 * @param custom Custom or not?
 * @return The elliptic curve parameters.
 */
private static ECParameterSpec getParameterSpec(String curveName, boolean custom) {
    if(custom) {
        X9ECParameters ecP = CustomNamedCurves.getByName(curveName);
        return new ECParameterSpec(ecP.getCurve(), ecP.getG(),
                ecP.getN(), ecP.getH(), ecP.getSeed());

    }
    return ECNamedCurveTable.getParameterSpec(curveName);
}
 
開發者ID:wkmeijer,項目名稱:CS4160-trustchain-android,代碼行數:16,代碼來源:Key.java

示例2: signAndFromatToRS

import org.spongycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
/**
 * UAF_ALG_SIGN_SECP256R1_ECDSA_SHA256_RAW 0x01
 * An ECDSA signature on the NIST secp256r1 curve which MUST have raw R and S buffers, encoded in big-endian order.
 * I.e. [R (32 bytes), S (32 bytes)]
 * 
 * @param priv - Private key
 * @param input - Data to sign 
 * @return BigInteger[] - [R,S]
 */
public static BigInteger[] signAndFromatToRS(PrivateKey priv, byte[] input) {
	X9ECParameters params = SECNamedCurves.getByName("secp256r1");
	ECDomainParameters ecParams = new ECDomainParameters(params.getCurve(),
			params.getG(), params.getN(), params.getH());
	if (priv == null)
		throw new IllegalStateException(
				"This ECKey does not have the private key necessary for signing.");
	ECDSASigner signer = new ECDSASigner();
	ECPrivateKeyParameters privKey = new ECPrivateKeyParameters(
			((ECPrivateKey) priv).getS(), ecParams);
	signer.init(true, privKey);
	BigInteger[] sigs = signer.generateSignature(input);
	return sigs;
}
 
開發者ID:zsavvas,項目名稱:ReCRED_FIDO_UAF_OIDC,代碼行數:24,代碼來源:NamedCurve.java

示例3: verify

import org.spongycastle.asn1.x9.X9ECParameters; //導入依賴的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

示例4: verify

import org.spongycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
public static boolean verify(byte[] pub, byte[] dataForSigning,
		BigInteger[] rs) {
	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:eBay,項目名稱:UAF,代碼行數:13,代碼來源:NamedCurve.java

示例5: getPublicKey

import org.spongycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
@Override
public byte[] getPublicKey(boolean compress, int... index) throws PinModeLockedException, UnusableIndexException, IOException, NoKeyLoadedException {
    DeterministicKey key = getKey(index);
    X9ECParameters params = SECNamedCurves.getByName("secp256k1");
    ECPoint point = params.getCurve().decodePoint(key.toECKey().getPubKey());
    point = new ECPoint.Fp(point.getCurve(), point.getX(), point.getY(), compress);
    return point.getEncoded();
}
 
開發者ID:Yubico,項目名稱:yubico-bitcoin-java,代碼行數:9,代碼來源:YkneoBitcoinSoft.java

示例6: convertParams

import org.spongycastle.asn1.x9.X9ECParameters; //導入依賴的package包/類
private static ECDomainParameters convertParams(X9ECParameters in) {
	return new ECDomainParameters(in.getCurve(), in.getG(), in.getN(),
			in.getH());
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:5,代碼來源:EllipticCurvePerformanceTest.java


注:本文中的org.spongycastle.asn1.x9.X9ECParameters類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。