本文整理汇总了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();
}
示例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();
}
示例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);
}
示例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());
}
示例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},});
}
示例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());
}
示例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
});
}
示例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},});
}