本文整理匯總了Java中org.spongycastle.asn1.x9.X9ECParameters.getG方法的典型用法代碼示例。如果您正苦於以下問題:Java X9ECParameters.getG方法的具體用法?Java X9ECParameters.getG怎麽用?Java X9ECParameters.getG使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.spongycastle.asn1.x9.X9ECParameters
的用法示例。
在下文中一共展示了X9ECParameters.getG方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例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;
}
示例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());
}
示例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());
}
示例5: 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());
}