Skip to content

Commit

Permalink
09543 d remove crypto class (#9544)
Browse files Browse the repository at this point in the history
Signed-off-by: Lazar Petrovic <lpetrovic05@gmail.com>
  • Loading branch information
lpetrovic05 committed Nov 2, 2023
1 parent 43c6178 commit d5343f0
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 312 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static com.swirlds.platform.StaticPlatformBuilder.doStaticSetup;
import static com.swirlds.platform.StaticPlatformBuilder.getGlobalMetrics;
import static com.swirlds.platform.StaticPlatformBuilder.getMetricsProvider;
import static com.swirlds.platform.crypto.CryptoSetup.initNodeSecurity;
import static com.swirlds.platform.crypto.CryptoStatic.initNodeSecurity;
import static com.swirlds.platform.gui.internal.BrowserWindowManager.getPlatforms;
import static com.swirlds.platform.state.signed.StartupStateUtils.getInitialState;
import static com.swirlds.platform.util.BootstrapUtils.checkNodesToRun;
Expand All @@ -45,6 +45,7 @@
import com.swirlds.platform.config.internal.PlatformConfigUtils;
import com.swirlds.platform.config.legacy.LegacyConfigProperties;
import com.swirlds.platform.config.legacy.LegacyConfigPropertiesLoader;
import com.swirlds.platform.crypto.KeysAndCerts;
import com.swirlds.platform.internal.SignedStateLoadingException;
import com.swirlds.platform.recovery.EmergencyRecoveryManager;
import com.swirlds.platform.state.State;
Expand Down Expand Up @@ -201,7 +202,7 @@ public Platform build() {

checkNodesToRun(List.of(selfId));

final Map<NodeId, Crypto> crypto = initNodeSecurity(configAddressBook, configuration);
final Map<NodeId, KeysAndCerts> keysAndCerts = initNodeSecurity(configAddressBook, configuration);
final PlatformContext platformContext = new DefaultPlatformContext(selfId, getMetricsProvider(), configuration);

// the AddressBook is not changed after this point, so we calculate the hash now
Expand Down Expand Up @@ -259,7 +260,7 @@ public Platform build() {

final SwirldsPlatform platform = new SwirldsPlatform(
platformContext,
crypto.get(selfId),
keysAndCerts.get(selfId),
recycleBin,
selfId,
appName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import com.swirlds.platform.components.wiring.ManualWiring;
import com.swirlds.platform.config.ThreadConfig;
import com.swirlds.platform.crypto.CryptoStatic;
import com.swirlds.platform.crypto.KeysAndCerts;
import com.swirlds.platform.crypto.PlatformSigner;
import com.swirlds.platform.dispatch.DispatchBuilder;
import com.swirlds.platform.dispatch.DispatchConfiguration;
Expand Down Expand Up @@ -203,7 +204,7 @@ public class SwirldsPlatform implements Platform {
private final ConsensusMetrics consensusMetrics;

/** the object that contains all key pairs and CSPRNG state for this member */
private final Crypto crypto;
private final KeysAndCerts keysAndCerts;
/**
* If a state was loaded from disk, this is the minimum generation non-ancient for that round. If starting from a
* genesis state, this is 0.
Expand Down Expand Up @@ -311,7 +312,7 @@ public class SwirldsPlatform implements Platform {
* the browser gives the Platform what app to run. There can be multiple Platforms on one computer.
*
* @param platformContext the context for this platform
* @param crypto an object holding all the public/private key pairs and the CSPRNG state for this
* @param keysAndCerts an object holding all the public/private key pairs and the CSPRNG state for this
* member
* @param recycleBin used to delete files that may be useful for later debugging
* @param id the ID for this node
Expand All @@ -323,7 +324,7 @@ public class SwirldsPlatform implements Platform {
*/
SwirldsPlatform(
@NonNull final PlatformContext platformContext,
@NonNull final Crypto crypto,
@NonNull final KeysAndCerts keysAndCerts,
@NonNull final RecycleBin recycleBin,
@NonNull final NodeId id,
@NonNull final String mainClassName,
Expand Down Expand Up @@ -383,7 +384,7 @@ public class SwirldsPlatform implements Platform {

this.shadowGraph = new ShadowGraph(syncMetrics, currentAddressBook.getSize());

this.crypto = crypto;
this.keysAndCerts = keysAndCerts;

EventCounter.registerEventCounterMetrics(metrics);

Expand Down Expand Up @@ -454,7 +455,7 @@ public class SwirldsPlatform implements Platform {
components.add(new IssMetrics(platformContext.getMetrics(), currentAddressBook));

stateManagementComponent = wiring.wireStateManagementComponent(
new PlatformSigner(crypto.getKeysAndCerts()),
new PlatformSigner(keysAndCerts),
actualMainClassName,
selfId,
swirldName,
Expand Down Expand Up @@ -671,7 +672,7 @@ public class SwirldsPlatform implements Platform {
platformContext,
threadManager,
time,
crypto,
keysAndCerts,
notificationEngine,
currentAddressBook,
selfId,
Expand Down Expand Up @@ -1162,7 +1163,7 @@ public NotificationEngine getNotificationEngine() {
*/
@Override
public Signature sign(final byte[] data) {
return crypto.sign(data);
return new PlatformSigner(keysAndCerts).sign(data);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* @param logStackTracePauseDuration
* If a thread takes longer than this duration to {@link StoppableThread#pause()}, log a stack trace for debugging
* purposes. A value of {@link Duration#ZERO} means never log.
* @param numCryptoThreads
* number of threads used to verify signatures and generate keys, in parallel
* @param threadPrioritySync
* priority for threads that sync (in SyncCaller, SyncListener, SyncServer)
* @param threadPriorityNonSync
Expand All @@ -41,7 +39,6 @@
@ConfigData("thread")
public record ThreadConfig(
@ConfigProperty(defaultValue = "5s") Duration logStackTracePauseDuration,
@ConfigProperty(defaultValue = "32") int numCryptoThreads,
@ConfigProperty(defaultValue = "5") int threadPrioritySync,
@ConfigProperty(defaultValue = "5") int threadPriorityNonSync,
@ConfigProperty(defaultValue = "0") long threadDumpPeriodMs,
Expand Down

This file was deleted.

0 comments on commit d5343f0

Please sign in to comment.