本文整理了Java中java.security.spec.ECPoint.<init>()
方法的一些代码示例,展示了ECPoint.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ECPoint.<init>()
方法的具体详情如下:
包路径:java.security.spec.ECPoint
类名称:ECPoint
方法名:<init>
[英]Creates a new point at the specified coordinates.
[中]在指定坐标处创建新点。
代码示例来源:origin: hierynomus/sshj
/**
* SECG 2.3.4 Octet String to ECPoint
*/
public static ECPoint getDecoded(byte[] M, EllipticCurve curve) {
int elementSize = getElementSize(curve);
if (M.length != 2 * elementSize + 1 || M[0] != 0x04) {
throw new SSHRuntimeException("Invalid 'f' for Elliptic Curve " + curve.toString());
}
byte[] xBytes = new byte[elementSize];
byte[] yBytes = new byte[elementSize];
System.arraycopy(M, 1, xBytes, 0, elementSize);
System.arraycopy(M, 1 + elementSize, yBytes, 0, elementSize);
return new ECPoint(new BigInteger(1, xBytes), new BigInteger(1, yBytes));
}
代码示例来源:origin: hierynomus/sshj
X9ECParameters ecParams = NISTNamedCurves.getByName(name);
ECNamedCurveSpec ecCurveSpec = new ECNamedCurveSpec(name, ecParams.getCurve(), ecParams.getG(), ecParams.getN());
ECPoint p = new ECPoint(bigX, bigY);
ECPublicKeySpec publicKeySpec = new ECPublicKeySpec(p, ecCurveSpec);
代码示例来源:origin: oracle/helidon
.orElse(null);
ECPoint point = new ECPoint(x, y);
this.publicKey = toPublicKey(kf, point, keySpec);
代码示例来源:origin: SeanDragon/protools
ECPoint g = new ECPoint(x, y);
代码示例来源:origin: i2p/i2p.i2p
private static ECPoint doublePoint(ECPoint r, EllipticCurve curve) {
if (r.equals(ECPoint.POINT_INFINITY))
return r;
BigInteger slope = (r.getAffineX().pow(2)).multiply(THREE);
slope = slope.add(curve.getA());
BigInteger prime = ((ECFieldFp) curve.getField()).getP();
// use NBI modInverse();
BigInteger tmp = r.getAffineY().multiply(TWO);
tmp = new NativeBigInteger(tmp);
slope = slope.multiply(tmp.modInverse(prime));
BigInteger xOut = slope.pow(2).subtract(r.getAffineX().multiply(TWO)).mod(prime);
BigInteger yOut = (r.getAffineY().negate()).add(slope.multiply(r.getAffineX().subtract(xOut))).mod(prime);
ECPoint out = new ECPoint(xOut, yOut);
return out;
}
代码示例来源:origin: i2p/i2p.i2p
private static ECPublicKey cvtToJavaECKey(SigningPublicKey pk)
throws GeneralSecurityException {
SigType type = pk.getType();
BigInteger[] xy = split(pk.getData());
ECPoint w = new ECPoint(xy[0], xy[1]);
// see ECConstants re: casting
ECPublicKeySpec ks = new ECPublicKeySpec(w, (ECParameterSpec) type.getParams());
KeyFactory kf = KeyFactory.getInstance("EC");
return (ECPublicKey) kf.generatePublic(ks);
}
代码示例来源:origin: i2p/i2p.i2p
public ECParameterSpec genSpec() {
BigInteger pb = new NativeBigInteger(ps);
BigInteger nb = new NativeBigInteger(ns);
BigInteger sb = new NativeBigInteger(ss.replace(" ", ""), 16);
BigInteger bb = new NativeBigInteger(bs.replace(" ", ""), 16);
BigInteger gxb = new NativeBigInteger(gxs.replace(" ", ""), 16);
BigInteger gyb = new NativeBigInteger(gys.replace(" ", ""), 16);
BigInteger ab = new NativeBigInteger(A.mod(pb));
ECField field = new ECFieldFp(pb);
EllipticCurve curve = new EllipticCurve(field, ab, bb, sb.toByteArray());
ECPoint g = new ECPoint(gxb, gyb);
return new ECParameterSpec(curve, g, nb, H);
}
}
代码示例来源:origin: i2p/i2p.i2p
private static ECPoint addPoint(ECPoint r, ECPoint s, EllipticCurve curve) {
if (r.equals(s))
return doublePoint(r, curve);
else if (r.equals(ECPoint.POINT_INFINITY))
return s;
else if (s.equals(ECPoint.POINT_INFINITY))
return r;
BigInteger prime = ((ECFieldFp) curve.getField()).getP();
// use NBI modInverse();
BigInteger tmp = r.getAffineX().subtract(s.getAffineX());
tmp = new NativeBigInteger(tmp);
BigInteger slope = (r.getAffineY().subtract(s.getAffineY())).multiply(tmp.modInverse(prime)).mod(prime);
slope = new NativeBigInteger(slope);
BigInteger xOut = (slope.modPow(TWO, prime).subtract(r.getAffineX())).subtract(s.getAffineX()).mod(prime);
BigInteger yOut = s.getAffineY().negate().mod(prime);
yOut = yOut.add(slope.multiply(s.getAffineX().subtract(xOut))).mod(prime);
ECPoint out = new ECPoint(xOut, yOut);
return out;
}
代码示例来源:origin: RUB-NDS/TLS-Attacker
@Override
public ECPoint getW() {
return new ECPoint(x, y);
}
代码示例来源:origin: org.apache.santuario/xmlsec
public static ECPoint decodePoint(byte[] encodedBytes, EllipticCurve elliptiCcurve) {
if (encodedBytes[0] != 0x04) {
throw new IllegalArgumentException("Only uncompressed format is supported");
}
int size = (elliptiCcurve.getField().getFieldSize() + 7) / 8;
byte affineXBytes[] = new byte[size];
byte affineYBytes[] = new byte[size];
System.arraycopy(encodedBytes, 1, affineXBytes, 0, size);
System.arraycopy(encodedBytes, size + 1, affineYBytes, 0, size);
return new ECPoint(new BigInteger(1, affineXBytes), new BigInteger(1, affineYBytes));
}
代码示例来源:origin: RUB-NDS/TLS-Attacker
private static PublicKey generateEcPublicKey(GOSTCurve curve, CustomECPoint point, String keyFactoryAlg) {
try {
ECParameterSpec ecParameterSpec = getEcParameterSpec(curve);
ECPoint ecPoint = new ECPoint(point.getX(), point.getY());
ECPublicKeySpec privateKeySpec = new ECPublicKeySpec(ecPoint, ecParameterSpec);
return KeyFactory.getInstance(keyFactoryAlg).generatePublic(privateKeySpec);
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
LOGGER.error("Could not generate GOST public key", e);
return null;
}
}
代码示例来源:origin: apache/cxf
public static ECPublicKey getECPublicKey(String curve, byte[] xPoint, byte[] yPoint) {
try {
ECParameterSpec params = getECParameterSpec(curve, false);
ECPoint ecPoint = new ECPoint(toBigInteger(xPoint),
toBigInteger(yPoint));
ECPublicKeySpec keySpec = new ECPublicKeySpec(ecPoint, params);
KeyFactory kf = KeyFactory.getInstance("EC");
return (ECPublicKey) kf.generatePublic(keySpec);
} catch (Exception ex) {
throw new SecurityException(ex);
}
}
private static BigInteger toBigInteger(byte[] bytes) {
代码示例来源:origin: org.apache.santuario/xmlsec
private static Curve initializeCurve(String name, String oid,
String sfield, String a, String b,
String x, String y, String n, int h) {
BigInteger p = bigInt(sfield);
ECField field = new ECFieldFp(p);
EllipticCurve curve = new EllipticCurve(field, bigInt(a),
bigInt(b));
ECPoint g = new ECPoint(bigInt(x), bigInt(y));
return new Curve(name, oid, curve, g, bigInt(n), h);
}
代码示例来源:origin: tiandawu/IotXmpp
private static PublicKey
toECDSAPublicKey(KEYBase r, ECKeyInfo keyinfo) throws IOException,
GeneralSecurityException, MalformedKeyException
{
DNSInput in = new DNSInput(r.getKey());
// RFC 6605 Section 4
BigInteger x = readBigInteger(in, keyinfo.length);
BigInteger y = readBigInteger(in, keyinfo.length);
ECPoint q = new ECPoint(x, y);
KeyFactory factory = KeyFactory.getInstance("EC");
return factory.generatePublic(new ECPublicKeySpec(q, keyinfo.spec));
}
代码示例来源:origin: com.madgag.spongycastle/prov
private ECParameterSpec createSpec(EllipticCurve ellipticCurve, ECDomainParameters dp)
{
return new ECParameterSpec(
ellipticCurve,
new ECPoint(
dp.getG().getAffineXCoord().toBigInteger(),
dp.getG().getAffineYCoord().toBigInteger()),
dp.getN(),
dp.getH().intValue());
}
代码示例来源:origin: com.madgag/scprov-jdk15on
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());
}
代码示例来源:origin: com.madgag/scprov-jdk15on
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());
}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
public static ECPoint convertPoint(org.bouncycastle.math.ec.ECPoint point)
{
point = point.normalize();
return new ECPoint(
point.getAffineXCoord().toBigInteger(),
point.getAffineYCoord().toBigInteger());
}
}
代码示例来源:origin: es.gob.afirma.jmulticard/jmulticard
@Override
public AlgorithmParameterSpec getEcPoint(final byte[] nonceS, final byte[] sharedSecretH, final EcCurve curveName) {
final AlgorithmParameterSpec ecParams = ECNamedCurveTable.getParameterSpec(curveName.toString());
final BigInteger affineX = os2i(sharedSecretH);
final BigInteger affineY = computeAffineY(affineX, (ECParameterSpec) ecParams);
final ECPoint sharedSecretPointH = new ECPoint(affineX, affineY);
return mapNonceGMWithECDH(os2i(nonceS), sharedSecretPointH, (ECParameterSpec) ecParams);
}
代码示例来源:origin: com.madgag.spongycastle/bcpkix-jdk15on
private java.security.spec.ECPoint getPublicPoint(ECDSAPublicKey key)
{
if (!key.hasParameters())
{
throw new IllegalArgumentException("Public key does not contains EC Params");
}
BigInteger p = key.getPrimeModulusP();
ECCurve.Fp curve = new ECCurve.Fp(p, key.getFirstCoefA(), key.getSecondCoefB(), key.getOrderOfBasePointR(), key.getCofactorF());
ECPoint.Fp pubY = (ECPoint.Fp)curve.decodePoint(key.getPublicPointY());
return new java.security.spec.ECPoint(pubY.getAffineXCoord().toBigInteger(), pubY.getAffineYCoord().toBigInteger());
}
内容来源于网络,如有侵权,请联系作者删除!