Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
cleanup before release
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-lizner committed Jul 4, 2016
1 parent e67cdd6 commit fa08e35
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 52 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/trezoragent/gui/TrayProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.trezoragent.mouselistener.JNIMouseHook;
import com.trezoragent.mouselistener.MouseClickOutsideComponentEvent;
import com.trezoragent.sshagent.DeviceService;
import com.trezoragent.sshagent.DeviceWrapper;
import com.trezoragent.sshagent.KeepKeyService;
import com.trezoragent.sshagent.SSHAgent;
import com.trezoragent.sshagent.TrezorService;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/trezoragent/sshagent/DeviceWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static void getIdentitiesRequest() { // directly used only for GUI calls
// Load settings from file
String bip32Path = AgentUtils.readSetting(settings, AgentConstants.SETTINGS_KEY_BIP32_URI, AgentConstants.SETTINGS_BIP32_SSHURI);
String bip32Index = AgentUtils.readSetting(settings, AgentConstants.SETTINGS_KEY_BIP32_INDEX, AgentConstants.SETTINGS_BIP32_INDEX);
//TODO: check that setting parameter is set to correct curve
String curveName = AgentUtils.readSetting(settings, AgentConstants.SETTINGS_KEY_CURVE_NAME, AgentConstants.CURVE_NAME_NISTP256);

TrayProcess.deviceService.getHardwareWalletService().requestPublicKeyForIdentity(URI.create(bip32Path), new Integer(bip32Index), curveName, false);
Expand Down
50 changes: 0 additions & 50 deletions src/main/java/com/trezoragent/utils/IdentityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import java.math.BigInteger;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.crypto.ChildNumber;
import org.spongycastle.jce.ECNamedCurveTable;
Expand All @@ -21,9 +20,6 @@
import java.security.spec.ECPublicKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.util.List;
import org.spongycastle.asn1.x9.X9ECParameters;
import org.spongycastle.crypto.ec.CustomNamedCurves;
import org.spongycastle.jce.spec.ECParameterSpec;

/**
* <p>
Expand Down Expand Up @@ -269,50 +265,4 @@ public static byte[] unframeUncompressedNistpKeyFromSSHKey(byte[] pubKeySSH) {
return compressedKey;
}

// PLAYGROUND for trying to construct Ed25519 verifier
public static ECPublicKey getEd25519PublicKeyFromBytes(byte[] pubKey) throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidAlgorithmParameterException {
X9ECParameters ecP = CustomNamedCurves.getByName("curve25519");
ECParameterSpec ecSpec = new ECParameterSpec(ecP.getCurve(), ecP.getG(), ecP.getN(), ecP.getH(), ecP.getSeed());

//org.spongycastle.math.ec.ECPoint decodePoint = ecSpec.getCurve().decodePoint(pubKey);

/*
Provider bcProvider = new BouncyCastleProvider();
KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", bcProvider);
g.initialize(ecSpec, new SecureRandom());
KeyPair keyPair = g.generateKeyPair();
System.out.println("getPublic: " + keyPair.getPublic());
*/
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("curve25519");
KeyFactory kf = KeyFactory.getInstance("ECDSA", new BouncyCastleProvider());
ECNamedCurveSpec params = new ECNamedCurveSpec("curve25519", spec.getCurve(), spec.getG(), spec.getN());
ECPoint point = ECPointUtil.decodePoint(params.getCurve(), pubKey);
ECPublicKeySpec pubKeySpec = new ECPublicKeySpec(point, params);
ECPublicKey pk = (ECPublicKey) kf.generatePublic(pubKeySpec);

return pk;
}

private static void testEd25519(byte[] pubKey) throws Exception {
String hexPubKeyXY_orig = "01f82bfb2f0a3e988adc3d053d8e6ff878154306e402d871b7d6000823a1397f";
String hexPubKeyXY = ByteUtils.toHexString(pubKey);

//BigInteger x16 = new BigInteger(ByteUtils.subArray(pubKey, 0, 15));
//BigInteger y16 = new BigInteger(ByteUtils.subArray(pubKey, 16, 32));
//ECPoint point = new ECPoint(x16, y16);
String hexX = hexPubKeyXY.substring(0, 32);
String hexY = hexPubKeyXY.substring(32);
ECPoint point = new ECPoint(new BigInteger(hexX, 16), new BigInteger(hexY, 16));

ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("curve25519");
KeyFactory kf = KeyFactory.getInstance("ECDSA", new BouncyCastleProvider());
ECNamedCurveSpec params = new ECNamedCurveSpec("curve25519", spec.getCurve(), spec.getG(), spec.getN());

ECPublicKeySpec pubKeySpec = new ECPublicKeySpec(point, params);
ECPublicKey pk = (ECPublicKey) kf.generatePublic(pubKeySpec);

System.out.println("PublicKey: " + pk);

}

}

0 comments on commit fa08e35

Please sign in to comment.