src/main/java/com/hedera/hashgraph/identity/hcs/MessageEnvelope.java
/**
   * Signs this message envelope with the given signing function.
   *
   * @param signer The signing function.
   * @return This envelope signed and serialized to JSON, ready for submission to HCS topic.
   */
Signs this message envelope with the given signing function.
@param signer The signing function.
@return This envelope signed and serialized to JSON, ready for submission to HCS topic.
Signs this message envelope with the given signing function . @param signer The signing function . @return This envelope signed and serialized to JSON ready for submission to HCS topic .
public byte[] sign(final UnaryOperator<byte[]> signer) {
    if (signer == null) {
      throw new IllegalArgumentException("Signing function is not provided.");
    }
    if (!Strings.isNullOrEmpty(signature)) {
      throw new IllegalStateException("Message is already signed.");
    }
    byte[] msgBytes = message.toJson().getBytes(StandardCharsets.UTF_8);
    byte[] signatureBytes = signer.apply(msgBytes);
    signature = new String(Base64.getEncoder().encode(signatureBytes), StandardCharsets.UTF_8);
    return toJson().getBytes(StandardCharsets.UTF_8);
  }
public byte [ ] sign ( final UnaryOperator < byte [ ] > signer ) { if ( signer == null ) { throw new IllegalArgumentException ( "Signing function is not provided." ) ; } if ( ! Strings . isNullOrEmpty ( signature ) ) { throw new IllegalStateException ( "Message is already signed." ) ; } byte [ ] msgBytes = message . toJson ( ) . getBytes ( StandardCharsets . UTF_8 ) ; byte [ ] signatureBytes = signer . apply ( msgBytes ) ; signature = new String ( Base64 . getEncoder ( ) . encode ( signatureBytes ) , StandardCharsets . UTF_8 ) ; return toJson ( ) . getBytes ( StandardCharsets . UTF_8 ) ; }
Signs this message envelope with the given signing function.
Signs this message envelope with the given signing function .