本文整理了Java中org.spongycastle.asn1.x9.X9IntegerConverter
类的一些代码示例,展示了X9IntegerConverter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X9IntegerConverter
类的具体详情如下:
包路径:org.spongycastle.asn1.x9.X9IntegerConverter
类名称:X9IntegerConverter
[英]A class which converts integers to byte arrays, allowing padding and calculations to be done according the the filed size of the curve or field element involved.
[中]一个将整数转换为字节数组的类,允许根据所涉及的曲线或字段元素的字段大小进行填充和计算。
代码示例来源:origin: ethereum/ethereumj
/**
* Decompress a compressed public key (x co-ord and low-bit of y-coord).
*
* @param xBN -
* @param yBit -
* @return -
*/
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);
}
代码示例来源:origin: com.madgag.spongycastle/prov
protected byte[] bigIntToBytes(
BigInteger r)
{
return converter.integerToBytes(r, converter.getByteLength(parameters.getCurve()));
}
代码示例来源:origin: com.madgag.spongycastle/prov
private void populateFromPubKeyInfo(SubjectPublicKeyInfo info)
{
X962Parameters params = X962Parameters.getInstance(info.getAlgorithm().getParameters());
ECCurve curve = EC5Util.getCurve(configuration, params);
ecSpec = EC5Util.convertToSpec(params, curve);
DERBitString bits = info.getPublicKeyData();
byte[] data = bits.getBytes();
ASN1OctetString key = new DEROctetString(data);
//
// extra octet string - one of our old certs...
//
if (data[0] == 0x04 && data[1] == data.length - 2
&& (data[2] == 0x02 || data[2] == 0x03))
{
int qLength = new X9IntegerConverter().getByteLength(curve);
if (qLength >= data.length - 3)
{
try
{
key = (ASN1OctetString) ASN1Primitive.fromByteArray(data);
}
catch (IOException ex)
{
throw new IllegalArgumentException("error recovering public key");
}
}
}
X9ECPoint derQ = new X9ECPoint(curve, key);
this.ecPublicKey = new ECPublicKeyParameters(derQ.getPoint(), ECUtil.getDomainParameters(configuration, params));
}
代码示例来源:origin: com.madgag/scprov-jdk15on
private byte[] bigIntToBytes(
BigInteger r)
{
return converter.integerToBytes(r, converter.getByteLength(parameters.getG().getX()));
}
代码示例来源:origin: com.madgag/scprov-jdk15on
&& (data[2] == 0x02 || data[2] == 0x03))
int qLength = new X9IntegerConverter().getByteLength(curve);
代码示例来源:origin: fr.acinq/bitcoinj-core
/** 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);
}
代码示例来源:origin: com.madgag/sc-light-jdk15on
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* FieldElement ::= OCTET STRING
* </pre>
* <p>
* <ol>
* <li> if <i>q</i> is an odd prime then the field element is
* processed as an Integer and converted to an octet string
* according to x 9.62 4.3.1.</li>
* <li> if <i>q</i> is 2<sup>m</sup> then the bit string
* contained in the field element is converted into an octet
* string with the same ordering padded at the front if necessary.
* </li>
* </ol>
*/
public ASN1Primitive toASN1Primitive()
{
int byteCount = converter.getByteLength(f);
byte[] paddedBigInteger = converter.integerToBytes(f.toBigInteger(), byteCount);
return new DEROctetString(paddedBigInteger);
}
}
代码示例来源:origin: com.madgag.spongycastle/prov
&& (data[2] == 0x02 || data[2] == 0x03))
int qLength = new X9IntegerConverter().getByteLength(curve);
代码示例来源:origin: HashEngineering/dashj
/** 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);
}
代码示例来源:origin: com.madgag.spongycastle/core
/**
* Produce an object suitable for an ASN1OutputStream.
* <pre>
* FieldElement ::= OCTET STRING
* </pre>
* <p>
* <ol>
* <li> if <i>q</i> is an odd prime then the field element is
* processed as an Integer and converted to an octet string
* according to x 9.62 4.3.1.</li>
* <li> if <i>q</i> is 2<sup>m</sup> then the bit string
* contained in the field element is converted into an octet
* string with the same ordering padded at the front if necessary.
* </li>
* </ol>
*/
public ASN1Primitive toASN1Primitive()
{
int byteCount = converter.getByteLength(f);
byte[] paddedBigInteger = converter.integerToBytes(f.toBigInteger(), byteCount);
return new DEROctetString(paddedBigInteger);
}
}
代码示例来源:origin: com.madgag/scprov-jdk15on
&& (data[2] == 0x02 || data[2] == 0x03))
int qLength = new X9IntegerConverter().getByteLength(curve);
代码示例来源:origin: com.google/bitcoinj
/** 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);
}
代码示例来源:origin: com.madgag/sc-light-jdk15on
int qLength = converter.getByteLength(x);
byte[] X = converter.integerToBytes(this.getX().toBigInteger(), qLength);
byte[] PO = new byte[X.length + 1];
byte[] X = converter.integerToBytes(this.getX().toBigInteger(), qLength);
byte[] Y = converter.integerToBytes(this.getY().toBigInteger(), qLength);
byte[] PO = new byte[X.length + Y.length + 1];
代码示例来源:origin: com.madgag/scprov-jdk15on
&& (data[2] == 0x02 || data[2] == 0x03))
int qLength = new X9IntegerConverter().getByteLength(curve);
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/** 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);
}
代码示例来源:origin: com.madgag/sc-light-jdk15on
int byteCount = converter.getByteLength(this.x);
byte[] X = converter.integerToBytes(this.getX().toBigInteger(), byteCount);
byte[] PO;
byte[] Y = converter.integerToBytes(this.getY().toBigInteger(), byteCount);
代码示例来源:origin: QuincySx/BlockchainWallet-Crypto
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);
}
代码示例来源:origin: greenaddress/GreenBits
/** 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);
}
代码示例来源:origin: yggdrash/yggdrash
/**
* Decompress a compressed public key (x co-ord and low-bit of y-coord).
*
* @param xBN -
* @param yBit -
* @return -
*/
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);
}
代码示例来源:origin: UlordChain/ulordj-thin
/** 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);
}
内容来源于网络,如有侵权,请联系作者删除!