net.i2p.crypto.eddsa.KeyPairGenerator kpg = new net.i2p.crypto.eddsa.KeyPairGenerator(); kpg.initialize(type.getParams(), _context.random()); kp = kpg.generateKeyPair(); } else { KeyPairGenerator kpg = KeyPairGenerator.getInstance(type.getBaseAlgorithm().getName());
/** * Creates a random ED25519 key pair. */ public Key() { KeyPair keypair = gen.generateKeyPair(); sk = (EdDSAPrivateKey) keypair.getPrivate(); pk = (EdDSAPublicKey) keypair.getPublic(); }
/** * Use this method once to generated an "authToken" which is the * combination of a random "user" and the hash of an EdDSA-key. * Persist the authToken somewhere, either in a static final, inside a property etc. * * @return An authToken to be used with the constructor of AirPlayAuth. */ public static String generateNewAuthToken() { String clientId = AuthUtils.randomString(16); return clientId + "@" + net.i2p.crypto.eddsa.Utils.bytesToHex(new KeyPairGenerator().generateKeyPair().getPrivate().getEncoded()); }