src/main/java/com/hedera/hashgraph/identity/hcs/did/HcsDidMessage.java
/**
   * Validates this DID message by checking its completeness, signature and DID document.
   *
   * @param didTopicId The DID topic ID against which the message is validated.
   * @return True if the message is valid, false otherwise.
   */
Validates this DID message by checking its completeness, signature and DID document.

@param didTopicId The DID topic ID against which the message is validated.
@return True if the message is valid, false otherwise.
Validates this DID message by checking its completeness signature and DID document . @param didTopicId The DID topic ID against which the message is validated . @return True if the message is valid false otherwise .
public boolean isValid(@Nullable final TopicId didTopicId) {
    if (did == null || didDocumentBase64 == null) {
      return false;
    }
    try {
      DidDocumentBase doc = DidDocumentBase.fromJson(getDidDocument());
      if (!did.equals(doc.getId())) {
        return false;
      }
      if (doc.getDidRootKey() == null || doc.getDidRootKey().getPublicKeyBase58() == null) {
        return false;
      }
      HcsDid hcsDid = HcsDid.fromString(did);
      byte[] publicKeyBytes = Base58.decode(doc.getDidRootKey().getPublicKeyBase58());
      PublicKey publicKey = PublicKey.fromBytes(publicKeyBytes);
      if (!HcsDid.publicKeyToIdString(publicKey).equals(hcsDid.getIdString())) {
        return false;
      }
      if (didTopicId != null && hcsDid.getDidTopicId() != null && !didTopicId.equals(hcsDid.getDidTopicId())) {
        return false;
      }
    } catch (IllegalArgumentException | ArrayIndexOutOfBoundsException e) {
      return false;
    }
    return true;
  }
public boolean isValid ( @ Nullable final TopicId didTopicId ) { if ( did == null || didDocumentBase64 == null ) { return false ; } try { DidDocumentBase doc = DidDocumentBase . fromJson ( getDidDocument ( ) ) ; if ( ! did . equals ( doc . getId ( ) ) ) { return false ; } if ( doc . getDidRootKey ( ) == null || doc . getDidRootKey ( ) . getPublicKeyBase58 ( ) == null ) { return false ; } HcsDid hcsDid = HcsDid . fromString ( did ) ; byte [ ] publicKeyBytes = Base58 . decode ( doc . getDidRootKey ( ) . getPublicKeyBase58 ( ) ) ; PublicKey publicKey = PublicKey . fromBytes ( publicKeyBytes ) ; if ( ! HcsDid . publicKeyToIdString ( publicKey ) . equals ( hcsDid . getIdString ( ) ) ) { return false ; } if ( didTopicId != null && hcsDid . getDidTopicId ( ) != null && ! didTopicId . equals ( hcsDid . getDidTopicId ( ) ) ) { return false ; } } catch ( IllegalArgumentException | ArrayIndexOutOfBoundsException e ) { return false ; } return true ; }
Validates this DID message by checking its completeness, signature and DID document.
Validates this DID message by checking its completeness signature and DID document .
// Validate if DID and DID document are present and match
 // Validate if DID root key is present in the document
 // Verify that DID was derived from this DID root key
 // Extract public key from the DID document
 // Verify that the message was sent to the right topic, if the DID contains the topic
