当前位置: 首页>>代码示例>>Java>>正文


Java PreimageSha256Condition类代码示例

本文整理汇总了Java中org.interledger.cryptoconditions.PreimageSha256Condition的典型用法代码示例。如果您正苦于以下问题:Java PreimageSha256Condition类的具体用法?Java PreimageSha256Condition怎么用?Java PreimageSha256Condition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PreimageSha256Condition类属于org.interledger.cryptoconditions包,在下文中一共展示了PreimageSha256Condition类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.interledger.cryptoconditions.PreimageSha256Condition; //导入依赖的package包/类
@Override
public InterledgerPaymentRequest read(final CodecContext context, final InputStream inputStream)
    throws IOException {
  Objects.requireNonNull(context);
  Objects.requireNonNull(inputStream);

  final int version = context.read(OerUint8.class, inputStream)
      .getValue();

  if (version != 2) {
    throw new RuntimeException("Unknown IPR version: " + version);
  }

  final InterledgerPayment packet = context.read(InterledgerPayment.class, inputStream);
  final PreimageSha256Condition condition
      = context.read(PreimageSha256Condition.class, inputStream);

  return InterledgerPaymentRequest.builder()
      .interledgerPayment(packet)
      .condition(condition)
      .build();
}
 
开发者ID:hyperledger,项目名称:quilt,代码行数:23,代码来源:InterledgerPaymentRequestOerCodec.java

示例2: read

import org.interledger.cryptoconditions.PreimageSha256Condition; //导入依赖的package包/类
@Override
public InterledgerPaymentRequest read(final CodecContext context, final InputStream inputStream)
    throws IOException {
  Objects.requireNonNull(context);
  Objects.requireNonNull(inputStream);

  final int version = context.read(OerUint8.class, inputStream)
      .getValue();

  if (version != 2) {
    throw new RuntimeException("Unknown IPR version: " + version);
  }

  final InterledgerPayment packet = context.read(InterledgerPayment.class, inputStream);
  final PreimageSha256Condition condition
      = context.read(PreimageSha256Condition.class, inputStream);

  return InterledgerPaymentRequest.builder()
      .payment(packet)
      .condition(condition)
      .build();
}
 
开发者ID:interledger,项目名称:java-ilp-core,代码行数:23,代码来源:InterledgerPaymentRequestOerCodec.java

示例3: read

import org.interledger.cryptoconditions.PreimageSha256Condition; //导入依赖的package包/类
@Override
public Condition read(final CodecContext context, final InputStream inputStream)
    throws IOException {
  Objects.requireNonNull(context);
  Objects.requireNonNull(inputStream);
  final byte[] value = context.read(OerUint256.class, inputStream)
      .getValue();

  //Cost (equal to the length of the preimage) is always 32 bytes in universal mode ILP
  return new PreimageSha256Condition(32, value);
}
 
开发者ID:hyperledger,项目名称:quilt,代码行数:12,代码来源:ConditionOerCodec.java

示例4: interledger

import org.interledger.cryptoconditions.PreimageSha256Condition; //导入依赖的package包/类
/**
 * Create an instance of {@link CodecContext} that encodes and decodes Interledger packets using
 * ASN.1 OER encoding.
 *
 * @return A new instance of {@link CodecContext}.
 */
public static CodecContext interledger() {

  // OER Base...
  return new CodecContext()
    .register(OerUint8.class, new OerUint8Codec())
    .register(OerUint32.class, new OerUint32Codec())
    .register(OerUint64.class, new OerUint64Codec())
    .register(OerUint256.class, new OerUint256Codec())
    .register(OerLengthPrefix.class, new OerLengthPrefixCodec())
    .register(OerIA5String.class, new OerIA5StringCodec())
    .register(OerOctetString.class, new OerOctetStringCodec())
    .register(OerGeneralizedTime.class, new OerGeneralizedTimeCodec())
    .register(OerSequenceOfAddress.class, new OerSequenceOfAddressCodec())

    // ILP
    .register(InterledgerAddress.class, new InterledgerAddressOerCodec())
    .register(InterledgerPacketType.class, new InterledgerPacketTypeOerCodec())
    .register(InterledgerPayment.class, new InterledgerPaymentOerCodec())
    .register(InterledgerProtocolError.class, new InterledgerProtocolProtocolErrorOerCodec())
    .register(InterledgerPaymentRequest.class, new InterledgerPaymentRequestOerCodec())
    .register(Condition.class, new ConditionOerCodec())
    .register(PreimageSha256Condition.class, new ConditionOerCodec())
    .register(Fulfillment.class, new FulfillmentOerCodec())
    .register(PreimageSha256Fulfillment.class, new FulfillmentOerCodec())

    // ILQP
    .register(QuoteByDestinationAmountRequest.class,
      new QuoteByDestinationAmountRequestOerCodec())
    .register(QuoteByDestinationAmountResponse.class,
      new QuoteByDestinationAmountResponseOerCodec())
    .register(QuoteBySourceAmountRequest.class, new QuoteBySourceAmountRequestOerCodec())
    .register(QuoteBySourceAmountResponse.class, new QuoteBySourceAmountResponseOerCodec())
    .register(QuoteLiquidityRequest.class, new QuoteLiquidityRequestOerCodec())
    .register(QuoteLiquidityResponse.class, new QuoteLiquidityResponseOerCodec())

    // PSK
    .register(PskMessage.class, new PskMessageBinaryCodec());
}
 
开发者ID:hyperledger,项目名称:quilt,代码行数:45,代码来源:CodecContextFactory.java

示例5: data

import org.interledger.cryptoconditions.PreimageSha256Condition; //导入依赖的package包/类
/**
 * The data for this test...
 */
@Parameters
public static Collection<Object[]> data() throws IOException {

  InterledgerPayment payment1 =
      InterledgerPayment.builder().destinationAccount(InterledgerAddress.of("test1.foo"))
          .destinationAmount(BigInteger.valueOf(100L)).data("test data".getBytes()).build();

  Condition condition1 = new PreimageSha256Condition(32, new byte[32]);

  InterledgerPaymentRequest ipr1 =
      InterledgerPaymentRequest.builder()
          .interledgerPayment(payment1).condition(condition1).build();

  InterledgerPayment payment2 =
      InterledgerPayment.builder().destinationAccount(InterledgerAddress.of("test2.bar"))
          .destinationAmount(BigInteger.ZERO).data("other data".getBytes()).build();

  Condition condition2 = new PreimageSha256Condition(32,
      new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
          1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
          1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2});

  InterledgerPaymentRequest ipr2 =
      InterledgerPaymentRequest.builder()
          .interledgerPayment(payment2).condition(condition2).build();

  return Arrays
      .asList(new Object[][]{{ipr1, payment1, condition1}, {ipr2, payment2, condition2},});
}
 
开发者ID:hyperledger,项目名称:quilt,代码行数:33,代码来源:InterledgerPaymentRequestTest.java

示例6: test

import org.interledger.cryptoconditions.PreimageSha256Condition; //导入依赖的package包/类
@Test
public final void test() {

  byte[] hash = new byte[32];
  assertArrayEquals("Hash is invalid.",
      hash,
      new PreimageSha256Condition(32, hash).getFingerprint());
}
 
开发者ID:hyperledger,项目名称:quilt,代码行数:9,代码来源:ConditionTest.java

示例7: data

import org.interledger.cryptoconditions.PreimageSha256Condition; //导入依赖的package包/类
/**
 * The data for this test...
 */
@Parameters
public static Collection<Object[]> data() {
  return Arrays.asList(new Object[][]{{new PreimageSha256Condition(32, new byte[32])},
      // TODO: Some more test values
  });
}
 
开发者ID:hyperledger,项目名称:quilt,代码行数:10,代码来源:ConditionOerCodecTests.java

示例8: data

import org.interledger.cryptoconditions.PreimageSha256Condition; //导入依赖的package包/类
/**
 * The data for this test...
 */
@Parameters
public static Collection<Object[]> data() throws IOException {

  InterledgerPayment payment1 =
      new InterledgerPayment.Builder().destinationAccount(InterledgerAddress.of("test1.foo"))
          .destinationAmount(BigInteger.valueOf(100L)).data("test data".getBytes()).build();

  Condition condition1 = new PreimageSha256Condition(32, new byte[32]);

  InterledgerPaymentRequest ipr1 =
      InterledgerPaymentRequest.builder().payment(payment1).condition(condition1).build();

  InterledgerPayment payment2 =
      new InterledgerPayment.Builder().destinationAccount(InterledgerAddress.of("test2.bar"))
          .destinationAmount(BigInteger.ZERO).data("other data".getBytes()).build();

  Condition condition2 = new PreimageSha256Condition(32,
      new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
          1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
          1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2});

  InterledgerPaymentRequest ipr2 =
      InterledgerPaymentRequest.builder().payment(payment2).condition(condition2).build();

  return Arrays
      .asList(new Object[][]{{ipr1, payment1, condition1}, {ipr2, payment2, condition2},});
}
 
开发者ID:interledger,项目名称:java-ilp-core,代码行数:31,代码来源:InterledgerPaymentRequestTest.java


注:本文中的org.interledger.cryptoconditions.PreimageSha256Condition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。