Example usage for org.bouncycastle.asn1.x9 X9IntegerConverter getByteLength

List of usage examples for org.bouncycastle.asn1.x9 X9IntegerConverter getByteLength

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.x9 X9IntegerConverter getByteLength.

Prototype

public int getByteLength(ECFieldElement fe) 

Source Link

Document

Return the field element's field size in bytes.

Usage

From source file:com.google.bitcoin.core.ECKey.java

License:Apache License

/** 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);
}