Search in sources :

Example 26 with X9IntegerConverter

use of org.bouncycastle.asn1.x9.X9IntegerConverter in project xdagj by XDagger.

the class Sign method decompressKey.

/**
 * Decompress a compressed public key (x co-ord and low-bit of y-coord).
 */
public static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
    X9IntegerConverter x9 = new X9IntegerConverter();
    byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
    compEnc[0] = (byte) (yBit ? 0x03 : 0x02);
    return CURVE.getCurve().decodePoint(compEnc);
}
Also used : X9IntegerConverter(org.bouncycastle.asn1.x9.X9IntegerConverter)

Example 27 with X9IntegerConverter

use of org.bouncycastle.asn1.x9.X9IntegerConverter in project Elastos.DID.Java.SDK by elastos.

the class ECKey method decompressKey.

/**
 * Decompress a compressed public key (x co-ord and low-bit of y-coord).
 */
private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {
    X9IntegerConverter x9 = new X9IntegerConverter();
    byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
    compEnc[0] = (byte) (yBit ? 0x03 : 0x02);
    return CURVE.getCurve().decodePoint(compEnc);
}
Also used : X9IntegerConverter(org.spongycastle.asn1.x9.X9IntegerConverter)

Example 28 with X9IntegerConverter

use of org.bouncycastle.asn1.x9.X9IntegerConverter in project digital-asset-wallet by dingan-work.

the class SECP256K1 method decompressKey.

/**
 * Decompress a compressed public key (x co-ord and low-bit of y-coord).
 */
private static ECPoint decompressKey(final BigInteger xBN, final boolean yBit) {
    final X9IntegerConverter x9 = new X9IntegerConverter();
    final byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));
    compEnc[0] = (byte) (yBit ? 0x03 : 0x02);
    // Currently ECCurve#decodePoint throws an IllegalArgumentException.
    return CURVE.getCurve().decodePoint(compEnc);
}
Also used : X9IntegerConverter(org.bouncycastle.asn1.x9.X9IntegerConverter)

Aggregations

X9IntegerConverter (org.bouncycastle.asn1.x9.X9IntegerConverter)18 X9IntegerConverter (org.spongycastle.asn1.x9.X9IntegerConverter)8 IOException (java.io.IOException)5 ECPoint (java.security.spec.ECPoint)5 ECParameterSpec (java.security.spec.ECParameterSpec)4 EllipticCurve (java.security.spec.EllipticCurve)4 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)3 DERBitString (org.bouncycastle.asn1.DERBitString)3 DEROctetString (org.bouncycastle.asn1.DEROctetString)3 X962Parameters (org.bouncycastle.asn1.x9.X962Parameters)3 X9ECParameters (org.bouncycastle.asn1.x9.X9ECParameters)3 X9ECPoint (org.bouncycastle.asn1.x9.X9ECPoint)3 ECNamedCurveSpec (org.bouncycastle.jce.spec.ECNamedCurveSpec)3 ECCurve (org.bouncycastle.math.ec.ECCurve)3 ASN1BitString (com.github.zhenwei.core.asn1.ASN1BitString)2 ASN1OctetString (com.github.zhenwei.core.asn1.ASN1OctetString)2 DEROctetString (com.github.zhenwei.core.asn1.DEROctetString)2 X962Parameters (com.github.zhenwei.core.asn1.x9.X962Parameters)2 X9ECPoint (com.github.zhenwei.core.asn1.x9.X9ECPoint)2 X9IntegerConverter (com.github.zhenwei.core.asn1.x9.X9IntegerConverter)2