novitski / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
Apache License 2.0
0 stars 0 forks source link

Alternate (simpler) ECKey.decompressKey implementation #493

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The current implementation of ECKey.decompressKey essentially duplicates the 
internal BC implementation. I suggest it is simpler (and more likely to pickup 
future BC improvements) to produce a compressed point encoding and let BC 
decode it, as follows:

        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);

We (BC) will probably add support for doing this directly without the encoding 
step, but in the meantime I think this is a better approach than the explicit 
calculation.

Original issue reported on code.google.com by peter.de...@gmail.com on 6 Dec 2013 at 5:01

GoogleCodeExporter commented 9 years ago
This issue was closed by revision f7a944983c28.

Original comment by hearn@google.com on 14 Dec 2013 at 10:13