Interface Signer

  • All Implemented Interfaces:

    
    public interface Signer
    
                        

    An interface defining the contract for signing and verifying signatures on payloads.

    Signer provides a generic approach to:

    • Creating digital signatures on payloads (sign)

    • Verifying digital signatures (verify)

    Implementers of this interface should ensure mechanisms provided for signing and verifying respect the cryptographic standards necessary for secure and valid operations.

    class MySigner : Signer {
        override fun sign(privateKey: Jwk , payload: Payload, options: SignOptions?): String {
            // Implementation-specific signing logic.
        }
    
        override fun verify(publicKey: Jwk , jws: String, options: VerifyOptions?) {
            // Implementation-specific verification logic.
        }
    }

    Implementers may utilize SignOptions and VerifyOptions to allow consumers to pass in additional, implementation-specific options to influence the signing and verification processes respectively.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract ByteArray sign(Jwk privateKey, ByteArray payload, SignOptions options) Sign a given payload using a private key.
      abstract Unit verify(Jwk publicKey, ByteArray signedPayload, ByteArray signature, VerifyOptions options) Verify the signature of a given payload using a public key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • sign

         abstract ByteArray sign(Jwk privateKey, ByteArray payload, SignOptions options)

        Sign a given payload using a private key.

        This function takes a payload and a private key in Jwk (JSON Web Key) format, and returns a signature as a byte array. Additional options for the signing process can be provided via the options parameter.

        Parameters:
        privateKey - The private key in Jwk format to be used for signing.
        payload - The payload/data to be signed.
        options - Optional parameter containing additional options to control the signing process.
        Returns:

        A ByteArray representing the signature.

      • verify

         abstract Unit verify(Jwk publicKey, ByteArray signedPayload, ByteArray signature, VerifyOptions options)

        Verify the signature of a given payload using a public key.

        This function attempts to verify the signature of a provided payload using a public key, supplied in Jwk (JSON Web Key) format, and a signature. The verification process checks the validity of the signature against the provided payload, respecting any optional verification options provided via VerifyOptions.

        Parameters:
        publicKey - The public key in Jwk format used for verifying the signature.
        signedPayload - The original payload/data that was signed, to be verified against its signature.
        signature - The signature to be verified against the payload and public key.
        options - Optional parameter containing additional options to control the verification process.