@@ -32,6 +32,8 @@ public class ECKeyPair {
3232 Security .addProvider (new BouncyCastleProvider ());
3333 }
3434
35+ private final NanoTDFType .ECCurve curve ;
36+
3537 public enum ECAlgorithm {
3638 ECDH ,
3739 ECDSA
@@ -40,13 +42,13 @@ public enum ECAlgorithm {
4042 private static final BouncyCastleProvider BOUNCY_CASTLE_PROVIDER = new BouncyCastleProvider ();
4143
4244 private KeyPair keyPair ;
43- private String curveName ;
4445
4546 public ECKeyPair () {
46- this ("secp256r1" , ECAlgorithm .ECDH );
47+ this (NanoTDFType . ECCurve . SECP256R1 , ECAlgorithm .ECDH );
4748 }
4849
49- public ECKeyPair (String curveName , ECAlgorithm algorithm ) {
50+ public ECKeyPair (NanoTDFType .ECCurve curve , ECAlgorithm algorithm ) {
51+ this .curve = curve ;
5052 KeyPairGenerator generator ;
5153
5254 try {
@@ -61,19 +63,13 @@ public ECKeyPair(String curveName, ECAlgorithm algorithm) {
6163 throw new RuntimeException (e );
6264 }
6365
64- ECGenParameterSpec spec = new ECGenParameterSpec (curveName );
66+ ECGenParameterSpec spec = new ECGenParameterSpec (this . curve . curveName );
6567 try {
6668 generator .initialize (spec );
6769 } catch (InvalidAlgorithmParameterException e ) {
6870 throw new RuntimeException (e );
6971 }
7072 this .keyPair = generator .generateKeyPair ();
71- this .curveName = curveName ;
72- }
73-
74- public ECKeyPair (ECPublicKey publicKey , ECPrivateKey privateKey , String curveName ) {
75- this .keyPair = new KeyPair (publicKey , privateKey );
76- this .curveName = curveName ;
7773 }
7874
7975 public ECPublicKey getPublicKey () {
@@ -118,10 +114,6 @@ public int keySize() {
118114 return this .keyPair .getPrivate ().getEncoded ().length * 8 ;
119115 }
120116
121- public String curveName () {
122- return this .curveName ;
123- }
124-
125117 public byte [] compressECPublickey () {
126118 return ((ECPublicKey ) this .keyPair .getPublic ()).getQ ().getEncoded (true );
127119 }
0 commit comments