AergoKey implements KeyPair, Signer { @Override public Transaction sign(final RawTransaction rawTransaction) { try { logger.debug("Sign raw transaction: {}", rawTransaction); final TxHash withoutSignature = rawTransaction.calculateHash(); final ECDSASignature ecdsaSignature = ecdsakey.sign(withoutSignature.getBytesValue().getValue()); final Signature signature = serialize(ecdsaSignature); logger.trace("Raw signature: {}", ecdsaSignature); logger.trace("Serialized signature: {}", signature); final TxHash withSignature = rawTransaction.calculateHash(signature); final Transaction transaction = Transaction.newBuilder() .rawTransaction(rawTransaction) .signature(signature) .hash(withSignature) .build(); return transaction; } catch (HerajException e) { throw e; } catch (Exception e) { throw new HerajException(e); } } AergoKey(final String encodedEncryptedPrivateKey, final String passphrase);  AergoKey(final EncryptedPrivateKey encryptedPrivateKey, final String passphrase);  AergoKey(final KeyFormat keyFormat, final String passphrase); protected <T extends Encrypted> AergoKey(final KeyCipherStrategy<T> strategy,
      final T encrypted, final String passphrase);  AergoKey(final ECDSAKey ecdsakey); static AergoKey of(final String encodedEncryptedPrivateKey, final String passphrase); static AergoKey of(final EncryptedPrivateKey encryptedPrivateKey,
      final String passphrase); static AergoKey of(final KeyFormat keyFormat, final String passphrase); @Override PrivateKey getPrivateKey(); @Override PublicKey getPublicKey(); @Override AccountAddress getPrincipal(); @Override Transaction sign(final RawTransaction rawTransaction); @Override Signature signMessage(final BytesValue message); @Override Signature signMessage(final Hash hashedMessage); EncryptedPrivateKey export(final String passphrase); EncryptedPrivateKey exportAsWif(final String passphrase); KeyFormat exportAsKeyFormat(final String passphrase); BytesValue getRawPrivateKey(); @Override String toString();  }
@Test public void testSignAndVerifyTransaction() throws Exception { final AergoSignVerifier verifier = new AergoSignVerifier(); for (int i = 0; i < N_TEST; ++i) { final AergoKey key = new AergoKeyGenerator().create(); final RawTransaction rawTransaction = RawTransaction.newBuilder(chainIdHash) .from(key.getAddress()) .to(key.getAddress()) .amount("10000", Unit.AER) .nonce(1L) .build(); final Transaction signedTransaction = key.sign(rawTransaction); assertTrue(verifier.verify(signedTransaction)); } }