org.spongycastle.asn1.x9.X9IntegerConverter.getByteLength()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中org.spongycastle.asn1.x9.X9IntegerConverter.getByteLength()方法的一些代码示例,展示了X9IntegerConverter.getByteLength()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X9IntegerConverter.getByteLength()方法的具体详情如下:
包路径:org.spongycastle.asn1.x9.X9IntegerConverter
类名称:X9IntegerConverter
方法名:getByteLength

X9IntegerConverter.getByteLength介绍

[英]Return the curve's field size in bytes.
[中]返回曲线的字段大小(字节)。

代码示例

代码示例来源: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/scprov-jdk15on

private byte[] bigIntToBytes(
  BigInteger    r)
{
  return converter.integerToBytes(r, converter.getByteLength(parameters.getG().getX()));
}

代码示例来源: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/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: 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: 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.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: 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: 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);
}

代码示例来源:origin: nebulasio/neb.java

/**
 * 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: tronprotocol/wallet-cli

/**
 * 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: CoinbaseWallet/toshi-headless-client

/**
 * 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: biheBlockChain/wkcwallet-java

/**
 * 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: AppStoreFoundation/asf-sdk

/**
 * 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/sc-light-jdk15on

int qLength = converter.getByteLength(x);

代码示例来源: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));
}

相关文章

微信公众号

最新文章

更多