public static byte[] toDerFormat(ECDSASignature signature) {
        try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
            DERSequenceGenerator seq = new DERSequenceGenerator(baos);
            seq.addObject(new ASN1Integer(signature.r));
            seq.addObject(new ASN1Integer(signature.s));
            seq.close();
            return baos.toByteArray();
        } catch (IOException ex) {
            return new byte[0];
        }
    }
@Test
    void toDerFormat() {
        byte[] signDER = CryptoUtils.toDerFormat(ecdsaSignatureExample);

        assertArrayEquals(Numeric.hexStringToByteArray(TX_SIGN_FORMAT_DER_HEX), signDER);
    }