docs: private byte[] ecdsaSignToBytes(ECPrivateKey privateKey, byte[] data) throws CryptoException {
          if (data == null) {
              throw new CryptoException("Data that to be signed is null.");
          }
          if (data.length == 0) {
              throw new CryptoException("Data to be signed was empty.");
          }
  
          try {
              X9ECParameters params = ECNamedCurveTable.getByName(curveName);
              BigInteger curveN = params.getN();
  
              Signature sig = SECURITY_PROVIDER == null ? Signature.getInstance(DEFAULT_SIGNATURE_ALGORITHM) :
                      Signature.getInstance(DEFAULT_SIGNATURE_ALGORITHM, SECURITY_PROVIDER);
              sig.initSign(privateKey);
              sig.update(data);
              byte[] signature = sig.sign();
  
              BigInteger[] sigs = decodeECDSASignature(signature);
  
              sigs = preventMalleability(sigs, curveN);
  
              try (ByteArrayOutputStream s = new ByteArrayOutputStream()) {
  
                  DERSequenceGenerator seq = new DERSequenceGenerator(s);
                  seq.addObject(new ASN1Integer(sigs[0]));
                  seq.addObject(new ASN1Integer(sigs[1]));
                  seq.close();
                  return s.toByteArray();
              }
  
          } catch (Exception e) {
              throw new CryptoException("Could not sign the message using private key", e);
          }
  
      }