Search in sources :

Example 11 with SigControl

use of com.hedera.services.bdd.spec.keys.SigControl in project hedera-services by hashgraph.

the class CryptoUpdateSuite method updateWithOneEffectiveSig.

private HapiApiSpec updateWithOneEffectiveSig() {
    KeyLabel ONE_UNIQUE_KEY = complex(complex("X", "X", "X", "X", "X", "X", "X"), complex("X", "X", "X", "X", "X", "X", "X"));
    SigControl SINGLE_SIG = KeyShape.threshSigs(2, KeyShape.threshSigs(1, OFF, OFF, OFF, OFF, OFF, OFF, OFF), KeyShape.threshSigs(3, OFF, OFF, OFF, ON, OFF, OFF, OFF));
    return defaultHapiSpec("UpdateWithOneEffectiveSig").given(newKeyNamed("repeatingKey").shape(TWO_LEVEL_THRESH).labels(ONE_UNIQUE_KEY), cryptoCreate(TARGET_ACCOUNT).key("repeatingKey").balance(1_000_000_000L)).when().then(cryptoUpdate(TARGET_ACCOUNT).sigControl(forKey("repeatingKey", SINGLE_SIG)).receiverSigRequired(true).hasKnownStatus(SUCCESS));
}
Also used : KeyLabel(com.hedera.services.bdd.spec.keys.KeyLabel) SigControl(com.hedera.services.bdd.spec.keys.SigControl)

Example 12 with SigControl

use of com.hedera.services.bdd.spec.keys.SigControl in project hedera-services by hashgraph.

the class CryptoUpdateSuite method updateFailsIfMissingSigs.

private HapiApiSpec updateFailsIfMissingSigs() {
    SigControl origKeySigs = KeyShape.threshSigs(3, ON, ON, KeyShape.threshSigs(1, OFF, ON));
    SigControl updKeySigs = KeyShape.listSigs(ON, OFF, KeyShape.threshSigs(1, ON, OFF, OFF, OFF));
    return defaultHapiSpec("UpdateFailsIfMissingSigs").given(newKeyNamed("origKey").shape(origKeySigs), newKeyNamed("updKey").shape(updKeySigs)).when(cryptoCreate("testAccount").receiverSigRequired(true).key("origKey").sigControl(forKey("origKey", origKeySigs))).then(cryptoUpdate("testAccount").key("updKey").sigControl(forKey("testAccount", origKeySigs), forKey("updKey", updKeySigs)).hasKnownStatus(INVALID_SIGNATURE));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl)

Example 13 with SigControl

use of com.hedera.services.bdd.spec.keys.SigControl in project hedera-services by hashgraph.

the class OverlappingKeysSuite method feeCalcUsesNumPayerKeys.

private HapiApiSpec feeCalcUsesNumPayerKeys() {
    SigControl SHAPE = threshSigs(2, threshSigs(2, ANY, ANY, ANY), threshSigs(2, ANY, ANY, ANY));
    KeyLabel ONE_UNIQUE_KEY = complex(complex("X", "X", "X"), complex("X", "X", "X"));
    SigControl SIGN_ONCE = threshSigs(2, threshSigs(3, ON, OFF, OFF), threshSigs(3, OFF, OFF, OFF));
    return defaultHapiSpec("PayerSigRedundancyRecognized").given(newKeyNamed("repeatingKey").shape(SHAPE).labels(ONE_UNIQUE_KEY), cryptoCreate("testAccount").key("repeatingKey").balance(1_000_000_000L)).when().then(QueryVerbs.getAccountInfo("testAccount").sigControl(forKey("repeatingKey", SIGN_ONCE)).payingWith("testAccount").numPayerSigs(5).hasAnswerOnlyPrecheck(INSUFFICIENT_TX_FEE), QueryVerbs.getAccountInfo("testAccount").sigControl(forKey("repeatingKey", SIGN_ONCE)).payingWith("testAccount").numPayerSigs(6));
}
Also used : KeyLabel(com.hedera.services.bdd.spec.keys.KeyLabel) SigControl(com.hedera.services.bdd.spec.keys.SigControl)

Example 14 with SigControl

use of com.hedera.services.bdd.spec.keys.SigControl in project hedera-services by hashgraph.

the class HapiFileCreate method generateWaclKey.

private void generateWaclKey(HapiApiSpec spec) {
    KeyGenerator generator = effectiveKeyGen();
    if (keyName.isPresent()) {
        waclKey = spec.registry().getKey(keyName.get());
        return;
    }
    if (waclControl.isPresent()) {
        SigControl control = waclControl.get();
        Assertions.assertEquals(SigControl.Nature.LIST, control.getNature(), "WACL must be a KeyList!");
        waclKey = spec.keys().generateSubjectTo(spec, control, generator);
    } else {
        waclKey = spec.keys().generate(spec, KeyFactory.KeyType.LIST, generator);
    }
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyGenerator(com.hedera.services.bdd.spec.keys.KeyGenerator)

Example 15 with SigControl

use of com.hedera.services.bdd.spec.keys.SigControl in project hedera-services by hashgraph.

the class R5BugChecks method enforcesSigRequirements.

private HapiApiSpec enforcesSigRequirements() {
    KeyShape complexSrShape = listOf(SIMPLE, threshOf(1, 3));
    SigControl activeSig = complexSrShape.signedWith(sigs(ON, sigs(OFF, OFF, ON)));
    SigControl inactiveSig = complexSrShape.signedWith(sigs(OFF, sigs(ON, ON, ON)));
    return defaultHapiSpec("EnforcesSigRequirements").given(newKeyNamed("srKey").shape(complexSrShape), fileCreate("bytecode").path(ContractResources.LAST_TRACKING_SENDER_BYTECODE_PATH), contractCreate("sponsor").bytecode("bytecode").balance(10), cryptoCreate("noSr").balance(0L), cryptoCreate("sr").key("srKey").balance(0L).receiverSigRequired(true)).when(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).hasKnownStatus(INVALID_SIGNATURE), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", inactiveSig)).hasKnownStatus(INVALID_SIGNATURE), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(0) }))), getAccountBalance("sr").hasTinyBars(0L)).then(contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("noSr").getAccountNum(), 1 }), contractCall("sponsor", ContractResources.TRACKING_SEND_ABI, spec -> new Object[] { (int) spec.registry().getAccountID("sr").getAccountNum(), 5 }).signedBy(GENESIS, "sr").sigControl(ControlForKey.forKey("sr", activeSig)), contractCallLocal("sponsor", ContractResources.HOW_MUCH_ABI).has(resultWith().resultThruAbi(ContractResources.HOW_MUCH_ABI, isLiteralResult(new Object[] { BigInteger.valueOf(5) }))), getAccountBalance("sr").hasTinyBars(5L), getAccountBalance("noSr").hasTinyBars(1L));
}
Also used : OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) SigControl(com.hedera.services.bdd.spec.keys.SigControl) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) ON(com.hedera.services.bdd.spec.keys.SigControl.ON) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) AccountInfoAsserts.changeFromSnapshot(com.hedera.services.bdd.spec.assertions.AccountInfoAsserts.changeFromSnapshot) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) QueryVerbs.contractCallLocal(com.hedera.services.bdd.spec.queries.QueryVerbs.contractCallLocal) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) BigInteger(java.math.BigInteger) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ControlForKey(com.hedera.services.bdd.spec.keys.ControlForKey) ContractFnResultAsserts.resultWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) KeyShape.threshOf(com.hedera.services.bdd.spec.keys.KeyShape.threshOf) ByteString(com.google.protobuf.ByteString) INVALID_ACCOUNT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_ID) List(java.util.List) Logger(org.apache.logging.log4j.Logger) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) KeyShape.sigs(com.hedera.services.bdd.spec.keys.KeyShape.sigs) TxnVerbs.fileDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileDelete) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) UtilVerbs.balanceSnapshot(com.hedera.services.bdd.spec.utilops.UtilVerbs.balanceSnapshot) TxnVerbs.fileUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileUpdate) AtomicReference(java.util.concurrent.atomic.AtomicReference) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) KeyShape.listOf(com.hedera.services.bdd.spec.keys.KeyShape.listOf) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TxnVerbs.cryptoDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoDelete) TxnVerbs.fileAppend(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileAppend) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) TransferList(com.hederahashgraph.api.proto.java.TransferList) QueryVerbs.getFileContents(com.hedera.services.bdd.spec.queries.QueryVerbs.getFileContents) FEE_SCHEDULE_FILE_PART_UPLOADED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FEE_SCHEDULE_FILE_PART_UPLOADED) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) QueryVerbs.getFileInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getFileInfo) ContractFnResultAsserts.isLiteralResult(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) Collectors.toList(java.util.stream.Collectors.toList) UtilVerbs.freezeOnly(com.hedera.services.bdd.spec.utilops.UtilVerbs.freezeOnly) OFF(com.hedera.services.bdd.spec.keys.SigControl.OFF) BAD_ENCODING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BAD_ENCODING) INVALID_SOLIDITY_ADDRESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SOLIDITY_ADDRESS) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) LogManager(org.apache.logging.log4j.LogManager) SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Aggregations

SigControl (com.hedera.services.bdd.spec.keys.SigControl)19 KeyShape (com.hedera.services.bdd.spec.keys.KeyShape)11 ByteString (com.google.protobuf.ByteString)2 KeyLabel (com.hedera.services.bdd.spec.keys.KeyLabel)2 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)1 HapiPropertySource (com.hedera.services.bdd.spec.HapiPropertySource)1 HapiPropertySource.asAccountString (com.hedera.services.bdd.spec.HapiPropertySource.asAccountString)1 HapiPropertySource.asTopicString (com.hedera.services.bdd.spec.HapiPropertySource.asTopicString)1 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)1 AccountInfoAsserts.changeFromSnapshot (com.hedera.services.bdd.spec.assertions.AccountInfoAsserts.changeFromSnapshot)1 ContractFnResultAsserts.isLiteralResult (com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult)1 ContractFnResultAsserts.resultWith (com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith)1 ContractResources (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources)1 ControlForKey (com.hedera.services.bdd.spec.keys.ControlForKey)1 KeyGenerator (com.hedera.services.bdd.spec.keys.KeyGenerator)1 SIMPLE (com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE)1 KeyShape.listOf (com.hedera.services.bdd.spec.keys.KeyShape.listOf)1 KeyShape.sigs (com.hedera.services.bdd.spec.keys.KeyShape.sigs)1 KeyShape.threshOf (com.hedera.services.bdd.spec.keys.KeyShape.threshOf)1