use of com.hedera.services.sigs.factories.ReusableBodySigningFactory 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());
}
}
}
}
use of com.hedera.services.sigs.factories.ReusableBodySigningFactory 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;
}
use of com.hedera.services.sigs.factories.ReusableBodySigningFactory in project hedera-services by hashgraph.
the class PrecheckVerifierTest method setupAll.
@BeforeAll
static void setupAll() throws Throwable {
reqKeys = List.of(KeyTree.withRoot(list(ed25519(), list(ed25519(), ed25519()))).asJKey(), KeyTree.withRoot(ed25519()).asJKey());
expectedSigs = PlatformSigOps.createCryptoSigsFrom(reqKeys, VALID_PROVIDER_FACTORY.get(), new ReusableBodySigningFactory(realAccessor)).getPlatformSigs();
}
use of com.hedera.services.sigs.factories.ReusableBodySigningFactory in project hedera-services by hashgraph.
the class PrecheckVerifier method getAvailSigs.
private List<TransactionSignature> getAvailSigs(List<JKey> reqKeys, SignedTxnAccessor accessor) throws Exception {
final var pkToSigFn = accessor.getPkToSigsFn();
final var sigFactory = new ReusableBodySigningFactory(accessor);
PlatformSigsCreationResult creationResult = createCryptoSigsFrom(reqKeys, pkToSigFn, sigFactory);
if (creationResult.hasFailed()) {
throw creationResult.getTerminatingEx();
} else {
return creationResult.getPlatformSigs();
}
}
use of com.hedera.services.sigs.factories.ReusableBodySigningFactory in project hedera-services by hashgraph.
the class HederaToPlatformSigOpsTest method rationalizesOnlyMissingSigs.
@Test
void rationalizesOnlyMissingSigs() throws Exception {
wellBehavedOrdersAndSigSources();
platformTxn.getPlatformTxn().addAll(asValid(expectedSigsWithOtherPartiesCreationError()).toArray(new TransactionSignature[0]));
final SyncVerifier syncVerifier = l -> {
if (l.equals(expectedSigsWithOtherPartiesCreationError())) {
throw new AssertionError("Payer sigs were verified async!");
} else {
ALWAYS_VALID.verifySync(l);
}
};
final var mockAccessor = mock(PlatformTxnAccessor.class);
final var captor = ArgumentCaptor.forClass(RationalizedSigMeta.class);
givenMirrorMock(mockAccessor, platformTxn);
final var rationalization = new Rationalization(syncVerifier, keyOrdering, new ReusableBodySigningFactory());
rationalization.performFor(mockAccessor);
assertTrue(rationalization.usedSyncVerification());
assertEquals(OK, rationalization.finalStatus());
verify(mockAccessor).setSigMeta(captor.capture());
final var sigMeta = captor.getValue();
platformTxn.setSigMeta(sigMeta);
assertEquals(expectedSigsWithNoErrors(), platformTxn.getSigMeta().verifiedSigs());
assertTrue(allVerificationStatusesAre(VerificationStatus.VALID::equals));
}
Aggregations