Search in sources :

Example 11 with JKey

use of com.hedera.services.legacy.core.jproto.JKey in project hedera-services by hashgraph.

the class CodeOrderResultFactoryTest method createsNewResultForValidOrder.

@Test
void createsNewResultForValidOrder() {
    // given:
    final List<JKey> pretendKeys = List.of(new JEd25519Key("IMAGINARY".getBytes(StandardCharsets.UTF_8)));
    // when:
    final var ans = subject.forValidOrder(pretendKeys);
    // then:
    assertSame(pretendKeys, ans.getOrderedKeys());
}
Also used : JKey(com.hedera.services.legacy.core.jproto.JKey) JEd25519Key(com.hedera.services.legacy.core.jproto.JEd25519Key) Test(org.junit.jupiter.api.Test)

Example 12 with JKey

use of com.hedera.services.legacy.core.jproto.JKey in project hedera-services by hashgraph.

the class SigOpsRegressionTest method otherPartySigsAreActive.

static boolean otherPartySigsAreActive(PlatformTxnAccessor accessor, SigRequirements keyOrder, SigningOrderResultFactory<ResponseCodeEnum> summaryFactory, KeyActivationCharacteristics characteristics) {
    TransactionBody txn = accessor.getTxn();
    Function<byte[], TransactionSignature> sigsFn = HederaKeyActivation.pkToSigMapFrom(accessor.getPlatformTxn().getSignatures());
    final var othersResult = keyOrder.keysForOtherParties(txn, summaryFactory);
    for (JKey otherKey : othersResult.getOrderedKeys()) {
        if (!HederaKeyActivation.isActive(otherKey, sigsFn, HederaKeyActivation.ONLY_IF_SIG_IS_VALID, characteristics)) {
            return false;
        }
    }
    return true;
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) JKey(com.hedera.services.legacy.core.jproto.JKey) TransactionSignature(com.swirlds.common.crypto.TransactionSignature)

Example 13 with JKey

use of com.hedera.services.legacy.core.jproto.JKey in project hedera-services by hashgraph.

the class PlatformSigOpsTest method doesntIgnoreUnrecognizedProblemForScheduledSig.

@Test
void doesntIgnoreUnrecognizedProblemForScheduledSig() throws Throwable {
    final JKey scheduledKey = new JEd25519Key("01234578901234578901234578901".getBytes());
    scheduledKey.setForScheduledTxn(true);
    given(sigBytes.sigBytesFor(any())).willThrow(IllegalStateException.class);
    final var result = createCryptoSigsFrom(List.of(scheduledKey), sigBytes, sigFactory);
    assertTrue(result.hasFailed());
}
Also used : JKey(com.hedera.services.legacy.core.jproto.JKey) JEd25519Key(com.hedera.services.legacy.core.jproto.JEd25519Key) Test(org.junit.jupiter.api.Test)

Aggregations

JKey (com.hedera.services.legacy.core.jproto.JKey)13 Test (org.junit.jupiter.api.Test)7 JEd25519Key (com.hedera.services.legacy.core.jproto.JEd25519Key)5 ArrayList (java.util.ArrayList)3 HederaAccountCustomizer (com.hedera.services.ledger.accounts.HederaAccountCustomizer)2 TransactionSignature (com.swirlds.common.crypto.TransactionSignature)2 ByteString (com.google.protobuf.ByteString)1 UnknownHederaFunctionality (com.hedera.services.exceptions.UnknownHederaFunctionality)1 JKeyList (com.hedera.services.legacy.core.jproto.JKeyList)1 MerkleAccount (com.hedera.services.state.merkle.MerkleAccount)1 MerkleToken (com.hedera.services.state.merkle.MerkleToken)1 EntityId (com.hedera.services.state.submerkle.EntityId)1 ExpirableTxnRecord (com.hedera.services.state.submerkle.ExpirableTxnRecord)1 FcTokenAllowance (com.hedera.services.state.submerkle.FcTokenAllowance)1 FcTokenAllowanceId (com.hedera.services.state.submerkle.FcTokenAllowanceId)1 EntityNum (com.hedera.services.utils.EntityNum)1 AccountAmount (com.hederahashgraph.api.proto.java.AccountAmount)1 AccountID (com.hederahashgraph.api.proto.java.AccountID)1 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)1 NftTransfer (com.hederahashgraph.api.proto.java.NftTransfer)1