Signature Value

Am I supposed to sign the ‘Signed Info’ or the ‘Hashed XML Invoice’?

Signing hashed xml invoice : -

byte[] canonicalizedBytes = Base64.getDecoder().decode(hashInvoiceValue.getBytes(StandardCharsets.UTF_8));Signature signature = Signature.getInstance("SHA256withECDSA","BC");signature.initSign(privateKey);signature.update(canonicalizedBytes);byte[] demSignature = signature.sign();String signatureValue = Base64.getEncoder().encodeToString(demSignature);

Signing signed info : -
{

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document doc = dbf.newDocumentBuilder().parse(
        new InputSource(new StringReader(signedInfoBlock))
);
Canonicalizer canonicalizer = Canonicalizer.getInstance(
        Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS
);
byte[] canonicalizedBytes = canonicalizer.canonicalizeSubtree(doc);
Signature signature = Signature.getInstance("SHA256withECDSA","BC");
signature.initSign(privateKey);
signature.update(canonicalizedBytes);
byte[] demSignature = signature.sign();
String signatureValue = Base64.getEncoder().encodeToString(demSignature);

}