@Test(expected = InvalidKeySpecException.class) public void loadKeysFromTrytes() throws InvalidKeySpecException, NoSuchAlgorithmException { Signer signer = new Signer(); signer.loadKeysFromTrytes("A", "B"); }
public void loadKeysFromTrytes(String privateKeyTrytes, String publicKeyTrytes) throws InvalidKeySpecException { byte[] privateKeyBytes = TryteTool.trytesToBytes(privateKeyTrytes); byte[] publicKeyBytes = TryteTool.trytesToBytes(publicKeyTrytes); try { KeyFactory kf = KeyFactory.getInstance(SignatureConstants.KEY_PAIR_GENERATOR_ALGORITHM); privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes)); publicKey = kf.generatePublic(new X509EncodedKeySpec(publicKeyBytes)); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } initSignature(); }
Signer { public void loadKeysFromTrytes(String privateKeyTrytes, String publicKeyTrytes) throws InvalidKeySpecException { byte[] privateKeyBytes = TryteTool.trytesToBytes(privateKeyTrytes); byte[] publicKeyBytes = TryteTool.trytesToBytes(publicKeyTrytes); try { KeyFactory kf = KeyFactory.getInstance(SignatureConstants.KEY_PAIR_GENERATOR_ALGORITHM); privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes)); publicKey = kf.generatePublic(new X509EncodedKeySpec(publicKeyBytes)); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } initSignature(); } }
Signer { public void loadKeysFromTrytes(String privateKeyTrytes, String publicKeyTrytes) throws InvalidKeySpecException { byte[] privateKeyBytes = TryteTool.trytesToBytes(privateKeyTrytes); byte[] publicKeyBytes = TryteTool.trytesToBytes(publicKeyTrytes); try { KeyFactory kf = KeyFactory.getInstance(SignatureConstants.KEY_PAIR_GENERATOR_ALGORITHM); privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes)); publicKey = kf.generatePublic(new X509EncodedKeySpec(publicKeyBytes)); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } initSignature(); } Signer(); }
Signer { public void loadKeysFromTrytes(String privateKeyTrytes, String publicKeyTrytes) throws InvalidKeySpecException { byte[] privateKeyBytes = TryteTool.trytesToBytes(privateKeyTrytes); byte[] publicKeyBytes = TryteTool.trytesToBytes(publicKeyTrytes); try { KeyFactory kf = KeyFactory.getInstance(SignatureConstants.KEY_PAIR_GENERATOR_ALGORITHM); privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes)); publicKey = kf.generatePublic(new X509EncodedKeySpec(publicKeyBytes)); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } initSignature(); } Signer(); String sign(String message); String getPublicKeyTrytes(); String getPrivateKeyTrytes(); void loadKeysFromTrytes(String privateKeyTrytes, String publicKeyTrytes); }
Signer { public void loadKeysFromTrytes(String privateKeyTrytes, String publicKeyTrytes) throws InvalidKeySpecException { byte[] privateKeyBytes = TryteTool.trytesToBytes(privateKeyTrytes); byte[] publicKeyBytes = TryteTool.trytesToBytes(publicKeyTrytes); try { KeyFactory kf = KeyFactory.getInstance(SignatureConstants.KEY_PAIR_GENERATOR_ALGORITHM); privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes)); publicKey = kf.generatePublic(new X509EncodedKeySpec(publicKeyBytes)); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } initSignature(); } Signer(); String sign(String message); String getPublicKeyTrytes(); String getPrivateKeyTrytes(); void loadKeysFromTrytes(String privateKeyTrytes, String publicKeyTrytes);  }