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));
}
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));
}
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));
}
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);
}
}
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));
}
Aggregations