本文整理汇总了Java中org.bouncycastle.crypto.params.ECDomainParameters.getN方法的典型用法代码示例。如果您正苦于以下问题:Java ECDomainParameters.getN方法的具体用法?Java ECDomainParameters.getN怎么用?Java ECDomainParameters.getN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.params.ECDomainParameters
的用法示例。
在下文中一共展示了ECDomainParameters.getN方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DSTU4145ECBinary
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
public DSTU4145ECBinary(ECDomainParameters params)
{
if (!(params.getCurve() instanceof ECCurve.F2m))
{
throw new IllegalArgumentException("only binary domain is possible");
}
// We always use big-endian in parameter encoding
ECCurve.F2m curve = (ECCurve.F2m)params.getCurve();
f = new DSTU4145BinaryField(curve.getM(), curve.getK1(), curve.getK2(), curve.getK3());
a = new ASN1Integer(curve.getA().toBigInteger());
X9IntegerConverter converter = new X9IntegerConverter();
b = new DEROctetString(converter.integerToBytes(curve.getB().toBigInteger(), converter.getByteLength(curve)));
n = new ASN1Integer(params.getN());
bp = new DEROctetString(DSTU4145PointEncoder.encodePoint(params.getG()));
}
示例2: JCEECPrivateKey
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
JCEECPrivateKey(
String algorithm,
ECPrivateKeyParameters params,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.d = params.getD();
if (spec == null)
{
this.ecSpec = new ECParameterSpec(
dp.getCurve(),
dp.getG(),
dp.getN(),
dp.getH(),
dp.getSeed());
}
else
{
this.ecSpec = spec;
}
}
示例3: JCEECPublicKey
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
JCEECPublicKey(
String algorithm,
ECPublicKeyParameters params,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.q = params.getQ();
if (spec == null)
{
this.ecSpec = new ECParameterSpec(
dp.getCurve(),
dp.getG(),
dp.getN(),
dp.getH(),
dp.getSeed());
}
else
{
this.ecSpec = spec;
}
}
示例4: transform
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
/**
* Transform an existing cipher text pair using the ElGamal algorithm. Note: the input cipherText will
* need to be preserved in order to complete the transformation to the new public key.
*
* @param cipherText the EC point to process.
* @return returns a new ECPair representing the result of the process.
*/
public ECPair transform(ECPair cipherText)
{
if (key == null)
{
throw new IllegalStateException("ECNewPublicKeyTransform not initialised");
}
ECDomainParameters ec = key.getParameters();
BigInteger n = ec.getN();
ECMultiplier basePointMultiplier = createBasePointMultiplier();
BigInteger k = ECUtil.generateK(n, random);
ECPoint[] gamma_phi = new ECPoint[]{
basePointMultiplier.multiply(ec.getG(), k),
key.getQ().multiply(k).add(cipherText.getY())
};
ec.getCurve().normalizeAll(gamma_phi);
return new ECPair(gamma_phi[0], gamma_phi[1]);
}
示例5: transform
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
/**
* Transform an existing cipher test pair using the ElGamal algorithm. Note: it is assumed this
* transform has been initialised with the same public key that was used to create the original
* cipher text.
*
* @param cipherText the EC point to process.
* @return returns a new ECPair representing the result of the process.
*/
public ECPair transform(ECPair cipherText)
{
if (key == null)
{
throw new IllegalStateException("ECNewRandomnessTransform not initialised");
}
ECDomainParameters ec = key.getParameters();
BigInteger n = ec.getN();
ECMultiplier basePointMultiplier = createBasePointMultiplier();
BigInteger k = ECUtil.generateK(n, random);
ECPoint[] gamma_phi = new ECPoint[]{
basePointMultiplier.multiply(ec.getG(), k).add(cipherText.getX()),
key.getQ().multiply(k).add(cipherText.getY())
};
ec.getCurve().normalizeAll(gamma_phi);
lastK = k;
return new ECPair(gamma_phi[0], gamma_phi[1]);
}
示例6: transform
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
/**
* Transform an existing cipher text pair using the ElGamal algorithm. Note: it is assumed this
* transform has been initialised with the same public key that was used to create the original
* cipher text.
*
* @param cipherText the EC point to process.
* @return returns a new ECPair representing the result of the process.
*/
public ECPair transform(ECPair cipherText)
{
if (key == null)
{
throw new IllegalStateException("ECFixedTransform not initialised");
}
ECDomainParameters ec = key.getParameters();
BigInteger n = ec.getN();
ECMultiplier basePointMultiplier = createBasePointMultiplier();
BigInteger k = this.k.mod(n);
ECPoint[] gamma_phi = new ECPoint[]{
basePointMultiplier.multiply(ec.getG(), k).add(cipherText.getX()),
key.getQ().multiply(k).add(cipherText.getY())
};
ec.getCurve().normalizeAll(gamma_phi);
return new ECPair(gamma_phi[0], gamma_phi[1]);
}
示例7: getParameterSpec
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
/**
* return a parameter spec representing the passed in named
* curve. The routine returns null if the curve is not present.
*
* @param name the name of the curve requested
* @return a parameter spec for the curve, null if it is not available.
*/
public static ECNamedCurveParameterSpec getParameterSpec(
String name)
{
ECDomainParameters ecP = ECGOST3410NamedCurves.getByName(name);
if (ecP == null)
{
try
{
ecP = ECGOST3410NamedCurves.getByOID(new ASN1ObjectIdentifier(name));
}
catch (IllegalArgumentException e)
{
return null; // not an oid.
}
}
if (ecP == null)
{
return null;
}
return new ECNamedCurveParameterSpec(
name,
ecP.getCurve(),
ecP.getG(),
ecP.getN(),
ecP.getH(),
ecP.getSeed());
}
示例8: JCEECPrivateKey
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
public JCEECPrivateKey(
String algorithm,
ECPrivateKeyParameters params,
JCEECPublicKey pubKey,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.d = params.getD();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = new ECParameterSpec(
ellipticCurve,
new ECPoint(
dp.getG().getX().toBigInteger(),
dp.getG().getY().toBigInteger()),
dp.getN(),
dp.getH().intValue());
}
else
{
this.ecSpec = spec;
}
publicKey = getPublicKeyDetails(pubKey);
}
示例9: createSpec
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
private ECParameterSpec createSpec(EllipticCurve ellipticCurve, ECDomainParameters dp)
{
return new ECParameterSpec(
ellipticCurve,
new ECPoint(
dp.getG().getX().toBigInteger(),
dp.getG().getY().toBigInteger()),
dp.getN(),
dp.getH().intValue());
}
示例10: BCDSTU4145PrivateKey
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
public BCDSTU4145PrivateKey(
String algorithm,
ECPrivateKeyParameters params,
BCDSTU4145PublicKey pubKey,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.d = params.getD();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = new ECParameterSpec(
ellipticCurve,
new ECPoint(
dp.getG().getX().toBigInteger(),
dp.getG().getY().toBigInteger()),
dp.getN(),
dp.getH().intValue());
}
else
{
this.ecSpec = spec;
}
publicKey = getPublicKeyDetails(pubKey);
}
示例11: createSpec
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
private ECParameterSpec createSpec(EllipticCurve ellipticCurve, ECDomainParameters dp)
{
return new ECParameterSpec(
ellipticCurve,
new ECPoint(
dp.getG().getX().toBigInteger(),
dp.getG().getY().toBigInteger()),
dp.getN(),
dp.getH().intValue());
}
示例12: BCECPrivateKey
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
public BCECPrivateKey(
String algorithm,
ECPrivateKeyParameters params,
BCECPublicKey pubKey,
ECParameterSpec spec,
ProviderConfiguration configuration)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.d = params.getD();
this.configuration = configuration;
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = new ECParameterSpec(
ellipticCurve,
new ECPoint(
dp.getG().getX().toBigInteger(),
dp.getG().getY().toBigInteger()),
dp.getN(),
dp.getH().intValue());
}
else
{
this.ecSpec = spec;
}
publicKey = getPublicKeyDetails(pubKey);
}
示例13: BCECGOST3410PrivateKey
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
public BCECGOST3410PrivateKey(
String algorithm,
ECPrivateKeyParameters params,
BCECGOST3410PublicKey pubKey,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.d = params.getD();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = new ECParameterSpec(
ellipticCurve,
new ECPoint(
dp.getG().getX().toBigInteger(),
dp.getG().getY().toBigInteger()),
dp.getN(),
dp.getH().intValue());
}
else
{
this.ecSpec = spec;
}
publicKey = getPublicKeyDetails(pubKey);
}
示例14: calculateMqvAgreement
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
private ECPoint calculateMqvAgreement(
ECDomainParameters parameters,
ECPrivateKeyParameters d1U,
ECPrivateKeyParameters d2U,
ECPublicKeyParameters Q2U,
ECPublicKeyParameters Q1V,
ECPublicKeyParameters Q2V)
{
BigInteger n = parameters.getN();
int e = (n.bitLength() + 1) / 2;
BigInteger powE = ECConstants.ONE.shiftLeft(e);
ECCurve curve = parameters.getCurve();
ECPoint[] points = new ECPoint[]{
// The Q2U public key is optional
ECAlgorithms.importPoint(curve, Q2U == null ? parameters.getG().multiply(d2U.getD()) : Q2U.getQ()),
ECAlgorithms.importPoint(curve, Q1V.getQ()),
ECAlgorithms.importPoint(curve, Q2V.getQ())
};
curve.normalizeAll(points);
ECPoint q2u = points[0], q1v = points[1], q2v = points[2];
BigInteger x = q2u.getAffineXCoord().toBigInteger();
BigInteger xBar = x.mod(powE);
BigInteger Q2UBar = xBar.setBit(e);
BigInteger s = d1U.getD().multiply(Q2UBar).add(d2U.getD()).mod(n);
BigInteger xPrime = q2v.getAffineXCoord().toBigInteger();
BigInteger xPrimeBar = xPrime.mod(powE);
BigInteger Q2VBar = xPrimeBar.setBit(e);
BigInteger hs = parameters.getH().multiply(s).mod(n);
return ECAlgorithms.sumOfTwoMultiplies(
q1v, Q2VBar.multiply(hs).mod(n), q2v, hs);
}
示例15: BCDSTU4145PrivateKey
import org.bouncycastle.crypto.params.ECDomainParameters; //导入方法依赖的package包/类
public BCDSTU4145PrivateKey(
String algorithm,
ECPrivateKeyParameters params,
BCDSTU4145PublicKey pubKey,
ECParameterSpec spec)
{
ECDomainParameters dp = params.getParameters();
this.algorithm = algorithm;
this.d = params.getD();
if (spec == null)
{
EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());
this.ecSpec = new ECParameterSpec(
ellipticCurve,
new ECPoint(
dp.getG().getAffineXCoord().toBigInteger(),
dp.getG().getAffineYCoord().toBigInteger()),
dp.getN(),
dp.getH().intValue());
}
else
{
this.ecSpec = spec;
}
publicKey = getPublicKeyDetails(pubKey);
}