public ECDSASignature sign(Sha256Hash input, @Nullable KeyParameter aesKey) throws KeyCrypterException {
        KeyCrypter crypter = getKeyCrypter();
        if (crypter != null) {
            if (aesKey == null)
                throw new KeyIsEncryptedException();
            return decrypt(aesKey).sign(input);
        } else {
            // No decryption of private key required.
            if (priv == null)
                throw new MissingPrivateKeyException();
        }
        return doSign(input, priv);
    }
public ECDSASignature sign ( Sha256Hash input , @ Nullable KeyParameter aesKey ) throws KeyCrypterException { KeyCrypter crypter = getKeyCrypter ( ) ; if ( crypter != null ) { if ( aesKey == null ) throw new KeyIsEncryptedException ( ) ; return decrypt ( aesKey ) . sign ( input ) ; } else { if ( priv == null ) throw new MissingPrivateKeyException ( ) ; } return doSign ( input , priv ) ; }
Signs the given hash and returns the R and S components as BigIntegers. In the Bitcoin protocol, they are
usually encoded using DER format, so you want {@link ECKey.ECDSASignature#encodeToDER()}
instead. However sometimes the independent components can be useful, for instance, if you're doing to do further
EC maths on them.

@param aesKey The AES key to use for decryption of the private key. If null then no decryption is required.
@throws KeyCrypterException if there's something wrong with aesKey.
@throws ECKey.MissingPrivateKeyException if this key cannot sign because it's pubkey only.