Skip to content

Commit

Permalink
feat: Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Holdt committed Jul 24, 2024
1 parent a25b67e commit f68eab1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 33 deletions.
3 changes: 0 additions & 3 deletions src/main/java/io/activeledger/ALPublicKey.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package io.activeledger;

import org.bouncycastle.jce.ECPointUtil;
import org.bouncycastle.util.encoders.Hex;

import java.math.BigInteger;
import java.security.*;
import java.security.spec.*;
import java.util.Arrays;

class ALPublicKey {
public static PublicKey hexToPublicKey(String hex) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, InvalidKeySpecException, InvalidParameterSpecException {
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/io/activeledger/KeyGenerator.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package io.activeledger;

import org.bouncycastle.asn1.x9.ECNamedCurveTable;
import org.bouncycastle.crypto.generators.ECKeyPairGenerator;
import org.bouncycastle.crypto.params.ECDomainParameters;
import org.bouncycastle.crypto.params.ECKeyGenerationParameters;
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey;
import org.bouncycastle.jce.interfaces.ECPublicKey;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.math.ec.ECPoint;
import org.bouncycastle.util.encoders.Hex;

import java.security.*;
import java.security.interfaces.ECPrivateKey;
import java.security.spec.ECGenParameterSpec;

public class KeyGenerator {
Expand All @@ -33,16 +27,10 @@ public ALKeyPair generate() throws InvalidAlgorithmParameterException, NoSuchAlg
rawPair = generator.generateKeyPair();

String prvKey;
// prvKey = "0x" + Hex.toHexString(rawPair.getPrivate().getEncoded());
prvKey = "0x" + getPrivateKey(rawPair.getPrivate());

String pubKey;
pubKey = "0x" + compressPublicKey(rawPair.getPublic());
// System.out.println("Private key hex: " + prvKey);
// System.out.println("Public key hex: " + pubKey);

// System.out.println("Private Key\n" + rawPair.getPrivate().toString());
// System.out.println("Public Key\n" + rawPair.getPublic().toString());

ALKeyPair pair;
pair = new ALKeyPair(prvKey, pubKey);
Expand All @@ -60,9 +48,6 @@ private String getPrivateKey(PrivateKey privateKey) {
String hex;
hex = Hex.toHexString(keyBytes);

// String unpadded;
// unpadded = removePadding(hex);

return hex;
}

Expand All @@ -72,11 +57,4 @@ private String compressPublicKey(PublicKey key) {
byte[] compressed = q.getEncoded(true);
return Hex.toHexString(compressed);
}

private String removePadding(String paddedKey) {
String key;
key = paddedKey.replaceFirst("^0+(?!$)", "");

return key;
}
}
8 changes: 0 additions & 8 deletions src/main/java/io/activeledger/Signer.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package io.activeledger;

import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.jce.spec.ECParameterSpec;
import org.bouncycastle.jce.spec.ECPrivateKeySpec;
//import org.bouncycastle.jce.spec.ECPublicKeySpec;
import org.bouncycastle.util.encoders.Hex;
//import org.bouncycastle.math.ec.ECPoint;

import javax.json.Json;
import javax.json.JsonObject;
Expand All @@ -15,10 +9,8 @@
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.math.BigInteger;
import java.security.*;
import java.security.spec.*;
import java.util.Arrays;
import java.util.Base64;

public class Signer {
Expand Down

0 comments on commit f68eab1

Please sign in to comment.