Search in sources :

Example 1 with SigRequirements

use of com.hedera.services.sigs.order.SigRequirements in project hedera-services by hashgraph.

the class SigOpsRegressionTest method setupFor.

private void setupFor(TxnHandlingScenario scenario) throws Throwable {
    hfs = scenario.hfs();
    aliasManager = mock(AliasManager.class);
    runningAvgs = mock(MiscRunningAvgs.class);
    speedometers = mock(MiscSpeedometers.class);
    accounts = scenario.accounts();
    platformTxn = scenario.platformTxn();
    expectedErrorStatus = null;
    final var hfsSigMetaLookup = new HfsSigMetaLookup(hfs, fileNumbers);
    signingOrder = new SigRequirements(defaultLookupsFor(aliasManager, hfsSigMetaLookup, () -> accounts, () -> null, ref -> null, ref -> null), mockSignatureWaivers);
    final var payerKeys = signingOrder.keysForPayer(platformTxn.getTxn(), CODE_ORDER_RESULT_FACTORY);
    expectedSigs = new ArrayList<>();
    if (payerKeys.hasErrorReport()) {
        expectedErrorStatus = payerKeys.getErrorReport();
    } else {
        PlatformSigsCreationResult payerResult = PlatformSigOps.createCryptoSigsFrom(payerKeys.getOrderedKeys(), new PojoSigMapPubKeyToSigBytes(platformTxn.getSigMap()), new ReusableBodySigningFactory(platformTxn));
        expectedSigs.addAll(payerResult.getPlatformSigs());
        SigningOrderResult<ResponseCodeEnum> otherKeys = signingOrder.keysForOtherParties(platformTxn.getTxn(), CODE_ORDER_RESULT_FACTORY);
        if (otherKeys.hasErrorReport()) {
            expectedErrorStatus = otherKeys.getErrorReport();
        } else {
            PlatformSigsCreationResult otherResult = PlatformSigOps.createCryptoSigsFrom(otherKeys.getOrderedKeys(), new PojoSigMapPubKeyToSigBytes(platformTxn.getSigMap()), new ReusableBodySigningFactory(platformTxn));
            if (!otherResult.hasFailed()) {
                expectedSigs.addAll(otherResult.getPlatformSigs());
            }
        }
    }
}
Also used : AliasManager(com.hedera.services.ledger.accounts.AliasManager) SigRequirements(com.hedera.services.sigs.order.SigRequirements) PojoSigMapPubKeyToSigBytes(com.hedera.services.sigs.sourcing.PojoSigMapPubKeyToSigBytes) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) MiscSpeedometers(com.hedera.services.stats.MiscSpeedometers) HfsSigMetaLookup(com.hedera.services.sigs.metadata.lookups.HfsSigMetaLookup) MiscRunningAvgs(com.hedera.services.stats.MiscRunningAvgs) ReusableBodySigningFactory(com.hedera.services.sigs.factories.ReusableBodySigningFactory)

Example 2 with SigRequirements

use of com.hedera.services.sigs.order.SigRequirements in project hedera-services by hashgraph.

the class SigOpsRegressionTest method invokeRationalizationScenario.

private Rationalization invokeRationalizationScenario() {
    // setup:
    SyncVerifier syncVerifier = new CryptoEngine()::verifySync;
    final var hfsSigMetaLookup = new HfsSigMetaLookup(hfs, fileNumbers);
    SigMetadataLookup sigMetaLookups = defaultLookupsFor(aliasManager, hfsSigMetaLookup, () -> accounts, () -> null, ref -> null, ref -> null);
    SigRequirements keyOrder = new SigRequirements(sigMetaLookups, mockSignatureWaivers);
    // given:
    final var rationalization = new Rationalization(syncVerifier, keyOrder, new ReusableBodySigningFactory());
    rationalization.performFor(platformTxn);
    return rationalization;
}
Also used : SyncVerifier(com.hedera.services.sigs.verification.SyncVerifier) SigRequirements(com.hedera.services.sigs.order.SigRequirements) CryptoEngine(com.swirlds.common.crypto.engine.CryptoEngine) HfsSigMetaLookup(com.hedera.services.sigs.metadata.lookups.HfsSigMetaLookup) SigMetadataLookup(com.hedera.services.sigs.metadata.SigMetadataLookup) ReusableBodySigningFactory(com.hedera.services.sigs.factories.ReusableBodySigningFactory)

Example 3 with SigRequirements

use of com.hedera.services.sigs.order.SigRequirements in project hedera-services by hashgraph.

the class SigVerifierRegressionTest method setupFor.

private void setupFor(TxnHandlingScenario scenario) throws Throwable {
    accounts = scenario.accounts();
    platformTxn = scenario.platformTxn();
    aliasManager = mock(AliasManager.class);
    keyOrder = new SigRequirements(defaultLookupsFor(aliasManager, null, () -> accounts, () -> null, ref -> null, ref -> null), mockSignatureWaivers);
    final var nodeInfo = mock(NodeInfo.class);
    given(nodeInfo.selfAccount()).willReturn(DEFAULT_NODE);
    isQueryPayment = PrecheckUtils.queryPaymentTestFor(nodeInfo);
    SyncVerifier syncVerifier = new CryptoEngine()::verifySync;
    precheckKeyReqs = new PrecheckKeyReqs(keyOrder, isQueryPayment);
    precheckVerifier = new PrecheckVerifier(syncVerifier, precheckKeyReqs);
}
Also used : SyncVerifier(com.hedera.services.sigs.verification.SyncVerifier) AliasManager(com.hedera.services.ledger.accounts.AliasManager) SigRequirements(com.hedera.services.sigs.order.SigRequirements) PrecheckKeyReqs(com.hedera.services.sigs.verification.PrecheckKeyReqs) PrecheckVerifier(com.hedera.services.sigs.verification.PrecheckVerifier) CryptoEngine(com.swirlds.common.crypto.engine.CryptoEngine)

Example 4 with SigRequirements

use of com.hedera.services.sigs.order.SigRequirements in project hedera-services by hashgraph.

the class SigOpsRegressionTest method invokeExpansionScenario.

private void invokeExpansionScenario() {
    final var hfsSigMetaLookup = new HfsSigMetaLookup(hfs, fileNumbers);
    SigMetadataLookup sigMetaLookups = defaultLookupsFor(aliasManager, hfsSigMetaLookup, () -> accounts, () -> null, ref -> null, ref -> null);
    SigRequirements keyOrder = new SigRequirements(sigMetaLookups, mockSignatureWaivers);
    final var pkToSigFn = new PojoSigMapPubKeyToSigBytes(platformTxn.getSigMap());
    expandIn(platformTxn, keyOrder, pkToSigFn);
}
Also used : SigRequirements(com.hedera.services.sigs.order.SigRequirements) PojoSigMapPubKeyToSigBytes(com.hedera.services.sigs.sourcing.PojoSigMapPubKeyToSigBytes) HfsSigMetaLookup(com.hedera.services.sigs.metadata.lookups.HfsSigMetaLookup) SigMetadataLookup(com.hedera.services.sigs.metadata.SigMetadataLookup)

Example 5 with SigRequirements

use of com.hedera.services.sigs.order.SigRequirements in project hedera-services by hashgraph.

the class SigOpsRegressionTest method invokePayerSigActivationScenario.

private boolean invokePayerSigActivationScenario(List<TransactionSignature> knownSigs) {
    SigRequirements keysOrder = new SigRequirements(defaultLookupsFor(aliasManager, null, () -> accounts, () -> null, ref -> null, ref -> null), mockSignatureWaivers);
    final var impliedOrdering = keysOrder.keysForPayer(platformTxn.getTxn(), CODE_ORDER_RESULT_FACTORY);
    final var impliedKey = impliedOrdering.getPayerKey();
    platformTxn.setSigMeta(RationalizedSigMeta.forPayerOnly(impliedKey, new ArrayList<>(knownSigs)));
    return payerSigIsActive(platformTxn, ONLY_IF_SIG_IS_VALID);
}
Also used : OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) MiscUtils.asKeyUnchecked(com.hedera.services.utils.MiscUtils.asKeyUnchecked) COMPLEX_KEY_ACCOUNT_KT(com.hedera.test.factories.scenarios.CryptoCreateScenarios.COMPLEX_KEY_ACCOUNT_KT) ONLY_IF_SIG_IS_VALID(com.hedera.services.keys.HederaKeyActivation.ONLY_IF_SIG_IS_VALID) SigRequirements(com.hedera.services.sigs.order.SigRequirements) HfsSigMetaLookup(com.hedera.services.sigs.metadata.lookups.HfsSigMetaLookup) CryptoEngine(com.swirlds.common.crypto.engine.CryptoEngine) SigWrappers.asValid(com.hedera.test.factories.sigs.SigWrappers.asValid) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) MerkleMap(com.swirlds.merkle.map.MerkleMap) CODE_ORDER_RESULT_FACTORY(com.hedera.services.sigs.order.CodeOrderResultFactory.CODE_ORDER_RESULT_FACTORY) EntityNum(com.hedera.services.utils.EntityNum) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) CRYPTO_UPDATE_COMPLEX_KEY_ACCOUNT_ADD_NEW_KEY_SCENARIO(com.hedera.test.factories.scenarios.CryptoUpdateScenarios.CRYPTO_UPDATE_COMPLEX_KEY_ACCOUNT_ADD_NEW_KEY_SCENARIO) PlatformTxnAccessor(com.hedera.services.utils.PlatformTxnAccessor) INVALID(com.swirlds.common.crypto.VerificationStatus.INVALID) SigningOrderResultFactory(com.hedera.services.sigs.order.SigningOrderResultFactory) Predicate(java.util.function.Predicate) CRYPTO_CREATE_RECEIVER_SIG_SCENARIO(com.hedera.test.factories.scenarios.CryptoCreateScenarios.CRYPTO_CREATE_RECEIVER_SIG_SCENARIO) PojoSigMapPubKeyToSigBytes(com.hedera.services.sigs.sourcing.PojoSigMapPubKeyToSigBytes) VerificationStatus(com.swirlds.common.crypto.VerificationStatus) RationalizedSigMeta(com.hedera.services.utils.RationalizedSigMeta) Test(org.junit.jupiter.api.Test) List(java.util.List) MiscRunningAvgs(com.hedera.services.stats.MiscRunningAvgs) DelegatingSigMetadataLookup.defaultLookupsFor(com.hedera.services.sigs.metadata.DelegatingSigMetadataLookup.defaultLookupsFor) JKey(com.hedera.services.legacy.core.jproto.JKey) SignatureWaivers(com.hedera.services.sigs.order.SignatureWaivers) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SyncVerifier(com.hedera.services.sigs.verification.SyncVerifier) PolicyBasedSigWaivers(com.hedera.services.sigs.order.PolicyBasedSigWaivers) MiscSpeedometers(com.hedera.services.stats.MiscSpeedometers) EntityNumbers(com.hedera.services.config.EntityNumbers) KeyActivationCharacteristics(com.hedera.services.keys.KeyActivationCharacteristics) NEW_ACCOUNT_KT(com.hedera.test.factories.scenarios.CryptoCreateScenarios.NEW_ACCOUNT_KT) FileNumbers(com.hedera.services.config.FileNumbers) HederaKeyActivation(com.hedera.services.keys.HederaKeyActivation) SystemOpPolicies(com.hedera.services.txns.auth.SystemOpPolicies) Function(java.util.function.Function) ArrayList(java.util.ArrayList) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) DEFAULT_ACTIVATION_CHARACTERISTICS(com.hedera.services.keys.DefaultActivationCharacteristics.DEFAULT_ACTIVATION_CHARACTERISTICS) CRYPTO_CREATE_COMPLEX_PAYER_RECEIVER_SIG_SCENARIO(com.hedera.test.factories.scenarios.CryptoCreateScenarios.CRYPTO_CREATE_COMPLEX_PAYER_RECEIVER_SIG_SCENARIO) DEFAULT_PAYER_KT(com.hedera.test.factories.txns.SignedTxnFactory.DEFAULT_PAYER_KT) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SigningOrderResult(com.hedera.services.sigs.order.SigningOrderResult) HederaToPlatformSigOps.expandIn(com.hedera.services.sigs.HederaToPlatformSigOps.expandIn) TxnHandlingScenario(com.hedera.test.factories.scenarios.TxnHandlingScenario) CryptoCreateFactory(com.hedera.test.factories.txns.CryptoCreateFactory) SigWrappers.asKind(com.hedera.test.factories.sigs.SigWrappers.asKind) ReusableBodySigningFactory(com.hedera.services.sigs.factories.ReusableBodySigningFactory) CRYPTO_UPDATE_COMPLEX_KEY_ACCOUNT_SCENARIO(com.hedera.test.factories.scenarios.CryptoUpdateScenarios.CRYPTO_UPDATE_COMPLEX_KEY_ACCOUNT_SCENARIO) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) VALID(com.swirlds.common.crypto.VerificationStatus.VALID) MockEntityNumbers(com.hedera.services.config.MockEntityNumbers) HederaFs(com.hedera.services.files.HederaFs) TransactionSignature(com.swirlds.common.crypto.TransactionSignature) HederaKeyActivation.payerSigIsActive(com.hedera.services.keys.HederaKeyActivation.payerSigIsActive) AbstractMap(java.util.AbstractMap) INVALID_PAYER_ID_SCENARIO(com.hedera.test.factories.scenarios.BadPayerScenarios.INVALID_PAYER_ID_SCENARIO) BDDMockito.mock(org.mockito.BDDMockito.mock) SigMetadataLookup(com.hedera.services.sigs.metadata.SigMetadataLookup) MockFileNumbers(com.hedera.services.config.MockFileNumbers) CRYPTO_UPDATE_MISSING_ACCOUNT_SCENARIO(com.hedera.test.factories.scenarios.CryptoUpdateScenarios.CRYPTO_UPDATE_MISSING_ACCOUNT_SCENARIO) AliasManager(com.hedera.services.ledger.accounts.AliasManager) SigRequirements(com.hedera.services.sigs.order.SigRequirements) ArrayList(java.util.ArrayList)

Aggregations

SigRequirements (com.hedera.services.sigs.order.SigRequirements)6 HfsSigMetaLookup (com.hedera.services.sigs.metadata.lookups.HfsSigMetaLookup)5 AliasManager (com.hedera.services.ledger.accounts.AliasManager)4 ReusableBodySigningFactory (com.hedera.services.sigs.factories.ReusableBodySigningFactory)4 SigMetadataLookup (com.hedera.services.sigs.metadata.SigMetadataLookup)4 PojoSigMapPubKeyToSigBytes (com.hedera.services.sigs.sourcing.PojoSigMapPubKeyToSigBytes)4 SyncVerifier (com.hedera.services.sigs.verification.SyncVerifier)4 MiscRunningAvgs (com.hedera.services.stats.MiscRunningAvgs)3 MiscSpeedometers (com.hedera.services.stats.MiscSpeedometers)3 EntityNumbers (com.hedera.services.config.EntityNumbers)2 FileNumbers (com.hedera.services.config.FileNumbers)2 MockEntityNumbers (com.hedera.services.config.MockEntityNumbers)2 MockFileNumbers (com.hedera.services.config.MockFileNumbers)2 HederaFs (com.hedera.services.files.HederaFs)2 DEFAULT_ACTIVATION_CHARACTERISTICS (com.hedera.services.keys.DefaultActivationCharacteristics.DEFAULT_ACTIVATION_CHARACTERISTICS)2 HederaKeyActivation (com.hedera.services.keys.HederaKeyActivation)2 ONLY_IF_SIG_IS_VALID (com.hedera.services.keys.HederaKeyActivation.ONLY_IF_SIG_IS_VALID)2 HederaKeyActivation.payerSigIsActive (com.hedera.services.keys.HederaKeyActivation.payerSigIsActive)2 KeyActivationCharacteristics (com.hedera.services.keys.KeyActivationCharacteristics)2 JKey (com.hedera.services.legacy.core.jproto.JKey)2