@@ -0,0 +1,2402 @@
+package org.interledger.everledger.common.util;%0A%0A//REF: http://stackoverflow.com/questions/9755057/converting-strings-to-encryption-keys-and-vice-versa-java%0A%0A// TODO:(0) Move to java-ilp-core/... utils/... ?%0Aimport java.security.*;%0Aimport java.security.spec.PKCS8EncodedKeySpec;%0Aimport java.security.spec.X509EncodedKeySpec;%0Aimport java.util.Arrays;%0Aimport java.util.Base64;%0Apublic class DSAPrivPubKeySupport %7B%0A public static PrivateKey loadPrivateKey(String key64) throws GeneralSecurityException %7B%0A     byte%5B%5D clear = Base64.getDecoder().decode(key64);%0A     PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(clear);%0A     KeyFactory fact = KeyFactory.getInstance(%22DSA%22);%0A     PrivateKey priv = fact.generatePrivate(keySpec);%0A     Arrays.fill(clear, (byte) 0);%0A     return priv;%0A %7D%0A%0A public static PublicKey loadPublicKey(String stored) throws GeneralSecurityException %7B%0A     byte%5B%5D data = Base64.getDecoder().decode(stored);%0A     X509EncodedKeySpec spec = new X509EncodedKeySpec(data);%0A     KeyFactory fact = KeyFactory.getInstance(%22DSA%22);%0A     return fact.generatePublic(spec);%0A %7D%0A%0A public static String savePrivateKey(PrivateKey priv) throws GeneralSecurityException %7B%0A     KeyFactory fact = KeyFactory.getInstance(%22DSA%22);%0A     PKCS8EncodedKeySpec spec = fact.getKeySpec(priv,%0A             PKCS8EncodedKeySpec.class);%0A     byte%5B%5D packed = spec.getEncoded();%0A     String key64 = new String(Base64.getEncoder().encode(packed));%0A     Arrays.fill(packed, (byte) 0);%0A     return key64;%0A %7D%0A%0A public static String savePublicKey(PublicKey publ) throws GeneralSecurityException %7B%0A     KeyFactory fact = KeyFactory.getInstance(%22DSA%22);%0A     X509EncodedKeySpec spec = fact.getKeySpec(publ,%0A             X509EncodedKeySpec.class);%0A     return new String(Base64.getEncoder().encode(spec.getEncoded()));%0A %7D%0A%0A public static void main(String%5B%5D args) throws Exception %7B%0A     KeyPairGenerator gen = KeyPairGenerator.getInstance(%22DSA%22);%0A     KeyPair pair = gen.generateKeyPair();%0A     String pubKey = savePublicKey(pair.getPublic());%0A     String privKey = savePrivateKey(pair.getPrivate());%0A     System.out.println(%22privKey:%22+privKey);%0A     System.out.println(%22pubKey :%22+pubKey );%0A     // PublicKey pubSaved = loadPublicKey(pubKey);%0A     // System.out.println(pair.getPublic()+%22%5Cn%22+pubSaved);%0A     // PrivateKey privSaved = loadPrivateKey(privKey);%0A     // System.out.println(pair.getPrivate()+%22%5Cn%22+privSaved);%0A %7D%0A%7D

Add Support to generate DSA-Ed25519 Pub/Priv Keys