Search in sources :

Example 16 with SigControl

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

the class GuidedTourRemoteSuite method topLevelHederaKeyMustBeActive.

private HapiApiSpec topLevelHederaKeyMustBeActive() {
    KeyShape waclShape = listOf(SIMPLE, threshOf(2, 3));
    SigControl updateSigControl = waclShape.signedWith(sigs(ON, sigs(ON, OFF, OFF)));
    return customHapiSpec("TopLevelListBehavesAsRevocationService").withProperties(Map.of("host", "34.74.191.8")).given().when().then(fileCreate("target").waclShape(waclShape).sigControl(ControlForKey.forKey("target", updateSigControl)).hasKnownStatus(INVALID_SIGNATURE));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 17 with SigControl

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

the class SubmitMessageSuite method messageSubmissionWithSubmitKey.

private HapiApiSpec messageSubmissionWithSubmitKey() {
    KeyShape submitKeyShape = threshOf(2, SIMPLE, SIMPLE, listOf(2));
    SigControl validSig = submitKeyShape.signedWith(sigs(ON, OFF, sigs(ON, ON)));
    SigControl invalidSig = submitKeyShape.signedWith(sigs(ON, OFF, sigs(ON, OFF)));
    return defaultHapiSpec("messageSubmissionWithSubmitKey").given(newKeyNamed("submitKey").shape(submitKeyShape), createTopic("testTopic").submitKeyName("submitKey")).when().then(submitMessageTo("testTopic").sigControl(forKey("testTopicSubmit", invalidSig)).hasRetryPrecheckFrom(BUSY).hasKnownStatus(INVALID_SIGNATURE), submitMessageTo("testTopic").sigControl(forKey("testTopicSubmit", validSig)).hasRetryPrecheckFrom(BUSY).hasKnownStatus(SUCCESS));
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape)

Example 18 with SigControl

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

the class NewSpecKeyList method submitOp.

@Override
protected boolean submitOp(HapiApiSpec spec) throws Throwable {
    List<Key> childKeys = keys.stream().map(spec.registry()::getKey).collect(toList());
    Key newList = Key.newBuilder().setKeyList(KeyList.newBuilder().addAllKeys(childKeys)).build();
    spec.registry().saveKey(name, newList);
    SigControl[] childControls = childKeys.stream().map(spec.keys()::controlFor).toArray(SigControl[]::new);
    spec.keys().setControl(newList, SigControl.listSigs(childControls));
    return false;
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) Key(com.hederahashgraph.api.proto.java.Key)

Example 19 with SigControl

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

the class ValidationScenarios method novelFileIfDesired.

private static HapiSpecOperation[] novelFileIfDesired() {
    if (!params.isNovelContent()) {
        return new HapiSpecOperation[0];
    }
    KeyShape firstComplex = KeyShape.listOf(KeyShape.threshOf(2, 3), KeyShape.threshOf(1, 3));
    KeyShape secondComplex = KeyShape.listOf(3);
    SigControl normalDelete = secondComplex.signedWith(KeyShape.sigs(ON, ON, ON));
    SigControl revocation = secondComplex.signedWith(KeyShape.sigs(ON, OFF, OFF));
    return new HapiSpecOperation[] { newKeyNamed("novelFileFirstKey").shape(firstComplex), newKeyNamed("novelFileSecondKey").shape(secondComplex), fileCreate(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).key("novelFileFirstKey").contents("abcdefghijklm"), fileAppend(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).content("nopqrstuvwxyz"), getFileContents(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).hasContents(ignore -> "abcdefghijklmnopqrstuvwxyz".getBytes()), fileUpdate(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).wacl("novelFileSecondKey"), fileDelete(NOVEL_FILE_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).sigControl(ControlForKey.forKey(NOVEL_FILE_NAME, params.isRevocationService() ? revocation : normalDelete)), withOpContext((spec, opLog) -> novelFileUsed.set(HapiPropertySource.asFileString(spec.registry().getFileId(NOVEL_FILE_NAME)))) };
}
Also used : SigControl(com.hedera.services.bdd.spec.keys.SigControl) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

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