examples/appnet-api-server/src/main/java/com/hedera/hashgraph/identity/hcs/example/appnet/vc/Ed25519CredentialProof.java
/**
   * Creates a linked data proof of type
   * Implementation is a simplified version for this example based on
   * https://github.com/WebOfTrustInfo/ld-signatures-java/.
   *
   * @param signingKey     Private key of the signing subject.
   * @param documentToSign The canonicalized JSON string of a verifiable credential document.
   */


@param signingKey     Private key of the signing subject.
@param documentToSign The canonicalized JSON string of a verifiable credential document.
@param signingKey Private key of the signing subject . @param documentToSign The canonicalized JSON string of a verifiable credential document .
public void sign(final PrivateKey signingKey, final String documentToSign) {
    byte[] inputForSigning = new byte[64];
    String normalizedProof = JsonUtils.getGson().toJson(toNormalizedJsonElement(true));
    byte[] normalizedDocHash = Hashing.sha256().hashBytes(documentToSign.getBytes(StandardCharsets.UTF_8))
            .asBytes();
    byte[] normalizedProofHash = Hashing.sha256().hashBytes(normalizedProof.getBytes(StandardCharsets.UTF_8))
            .asBytes();
    System.arraycopy(normalizedProofHash, 0, inputForSigning, 0, 32);
    System.arraycopy(normalizedDocHash, 0, inputForSigning, 32, 32);
    JWSHeader jwsHeader = new JWSHeader.Builder(JWSAlgorithm.EdDSA).customParam("b64", Boolean.FALSE)
            .criticalParams(Collections.singleton("b64")).build();
    byte[] jwsSigningInput = getJwsSigningInput(jwsHeader, inputForSigning);
    Base64URL signature = Base64URL.encode(signingKey.sign(jwsSigningInput));
    setJws(jwsHeader.toBase64URL().toString() + '.' + '.' + signature.toString());
  }
public void sign ( final PrivateKey signingKey , final String documentToSign ) { byte [ ] inputForSigning = new byte [ 64 ] ; String normalizedProof = JsonUtils . getGson ( ) . toJson ( toNormalizedJsonElement ( true ) ) ; byte [ ] normalizedDocHash = Hashing . sha256 ( ) . hashBytes ( documentToSign . getBytes ( StandardCharsets . UTF_8 ) ) . asBytes ( ) ; byte [ ] normalizedProofHash = Hashing . sha256 ( ) . hashBytes ( normalizedProof . getBytes ( StandardCharsets . UTF_8 ) ) . asBytes ( ) ; System . arraycopy ( normalizedProofHash , 0 , inputForSigning , 0 , 32 ) ; System . arraycopy ( normalizedDocHash , 0 , inputForSigning , 32 , 32 ) ; JWSHeader jwsHeader = new JWSHeader . Builder ( JWSAlgorithm . EdDSA ) . customParam ( "b64" , Boolean . FALSE ) . criticalParams ( Collections . singleton ( "b64" ) ) . build ( ) ; byte [ ] jwsSigningInput = getJwsSigningInput ( jwsHeader , inputForSigning ) ; Base64URL signature = Base64URL . encode ( signingKey . sign ( jwsSigningInput ) ) ; setJws ( jwsHeader . toBase64URL ( ) . toString ( ) + '.' + '.' + signature . toString ( ) ) ; }
Creates a linked data proof of type
 Implementation is a simplified version for this example based on
 https://github.com/WebOfTrustInfo/ld-signatures-java/.
Creates a linked data proof of type Implementation is a simplified version for this example based on https : // github . com / WebOfTrustInfo / ld - signatures - java / .