Interface Sign.Native

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean convertPublicKeyEd25519ToCurve25519​(byte[] curve, byte[] ed)
      Converts a public ed25519 key to a public curve25519 key.
      boolean convertSecretKeyEd25519ToCurve25519​(byte[] curve, byte[] ed)
      Converts a secret ed25519 key to a secret curve25519 key.
      boolean cryptoSign​(byte[] signedMessage, byte[] message, long messageLen, byte[] secretKey)
      Sign a message.
      boolean cryptoSignDetached​(byte[] signature, byte[] message, long messageLen, byte[] secretKey)
      Returns a signature for a message.
      boolean cryptoSignEd25519SkToPk​(byte[] publicKey, byte[] ed)
      Extracts the ed25519 public key from a secret ed25519 key.
      boolean cryptoSignEd25519SkToSeed​(byte[] seed, byte[] ed)
      Extracts the seed value from a secret ed25519 key.
      boolean cryptoSignFinalCreate​(Sign.StateCryptoSign state, byte[] sig, com.sun.jna.Pointer sigLen, byte[] sk)
      This function computes a signature for the previously supplied message, using the secret key sk and puts it into sig.
      boolean cryptoSignFinalVerify​(Sign.StateCryptoSign state, byte[] sig, byte[] pk)
      Verifies that sig is a valid signature for the message whose content has been previously supplied using crypto_update(), using the public key pk.
      boolean cryptoSignInit​(Sign.StateCryptoSign state)
      Useful for signing a multi-part message (Ed25519ph).
      boolean cryptoSignKeypair​(byte[] publicKey, byte[] secretKey)
      Generate a signing keypair (ed25519).
      boolean cryptoSignOpen​(byte[] message, byte[] signedMessage, long signedMessageLen, byte[] publicKey)
      Verify a signed message.
      boolean cryptoSignSeedKeypair​(byte[] publicKey, byte[] secretKey, byte[] seed)
      Deterministically generate a public and secret key.
      boolean cryptoSignUpdate​(Sign.StateCryptoSign state, byte[] chunk, long chunkLength)
      Add a new chunk of length chunkLen bytes to the message that will eventually be signed.
      boolean cryptoSignVerifyDetached​(byte[] signature, byte[] message, int messageLen, byte[] publicKey)
      Verifies that signature is valid for the message.
    • Method Detail

      • cryptoSignInit

        boolean cryptoSignInit​(Sign.StateCryptoSign state)
        Useful for signing a multi-part message (Ed25519ph). If the message can fit in memory and can be supplied as a single chunk, the single-part API should be preferred. This function must be called before the first crypto_sign_update() call.
        Parameters:
        state - The state.
        Returns:
        True if successful.
      • cryptoSignUpdate

        boolean cryptoSignUpdate​(Sign.StateCryptoSign state,
                                 byte[] chunk,
                                 long chunkLength)
        Add a new chunk of length chunkLen bytes to the message that will eventually be signed.
        Parameters:
        state - The state.
        chunk - A part of the long message.
        chunkLength - Message length.
        Returns:
        True if this chunk was successfully signed.
      • cryptoSignFinalCreate

        boolean cryptoSignFinalCreate​(Sign.StateCryptoSign state,
                                      byte[] sig,
                                      com.sun.jna.Pointer sigLen,
                                      byte[] sk)
        This function computes a signature for the previously supplied message, using the secret key sk and puts it into sig. If sigLen is not NULL, the length of the signature is stored at this address. However this is kind of redundant as you can just do sig.length.
        Parameters:
        state - The state.
        sig - Resultant signature.
        sigLen - Signature length.
        sk - Secret key.
        Returns:
        True if successfully signed completely.
      • cryptoSignFinalVerify

        boolean cryptoSignFinalVerify​(Sign.StateCryptoSign state,
                                      byte[] sig,
                                      byte[] pk)
        Verifies that sig is a valid signature for the message whose content has been previously supplied using crypto_update(), using the public key pk.
        Parameters:
        state - The state.
        sig - Resultant signature.
        pk - Secret key.
        Returns:
        True if successfully signed completely.
      • cryptoSignKeypair

        boolean cryptoSignKeypair​(byte[] publicKey,
                                  byte[] secretKey)
        Generate a signing keypair (ed25519).
        Parameters:
        publicKey - Public key.
        secretKey - Secret key.
        Returns:
        True if successful.
      • cryptoSignSeedKeypair

        boolean cryptoSignSeedKeypair​(byte[] publicKey,
                                      byte[] secretKey,
                                      byte[] seed)
        Deterministically generate a public and secret key.
        Parameters:
        publicKey - Public key.
        secretKey - Secret key.
        seed - The seed used to generate the keys.
        Returns:
        True if successfully generated keys.
      • cryptoSign

        boolean cryptoSign​(byte[] signedMessage,
                           byte[] message,
                           long messageLen,
                           byte[] secretKey)
        Sign a message.
        Parameters:
        signedMessage - Signed message will be placed here. It is Sign.BYTES + messageLen long.
        message - The message.
        messageLen - The message length.
        secretKey - The secret key.
        Returns:
        True if successfully signed.
      • cryptoSignOpen

        boolean cryptoSignOpen​(byte[] message,
                               byte[] signedMessage,
                               long signedMessageLen,
                               byte[] publicKey)
        Verify a signed message.
        Parameters:
        message - The message will be placed in here.
        signedMessage - The signed message.
        signedMessageLen - The signed message length.
        publicKey - Public key.
        Returns:
        True if the signature is from the public key.
      • cryptoSignDetached

        boolean cryptoSignDetached​(byte[] signature,
                                   byte[] message,
                                   long messageLen,
                                   byte[] secretKey)
        Returns a signature for a message. This does not prepend the signature to the message. See cryptoSign(byte[], byte[], long, byte[]) for that.
        Parameters:
        signature - The signature will be added to this byte array.
        message - The message to sign.
        messageLen - The message length.
        secretKey - The secret key.
        Returns:
        True if the secret key could provide a signature.
      • cryptoSignVerifyDetached

        boolean cryptoSignVerifyDetached​(byte[] signature,
                                         byte[] message,
                                         int messageLen,
                                         byte[] publicKey)
        Verifies that signature is valid for the message.
        Parameters:
        signature - The signature.
        message - The message.
        messageLen - The message length.
        publicKey - The public key that signed the message.
        Returns:
        Returns true if the signature is valid for the message.
        See Also:
        cryptoSignDetached(byte[], byte[], long, byte[])
      • convertPublicKeyEd25519ToCurve25519

        boolean convertPublicKeyEd25519ToCurve25519​(byte[] curve,
                                                    byte[] ed)
        Converts a public ed25519 key to a public curve25519 key.
        Parameters:
        curve - The array in which the generated key will be placed.
        ed - The public key in ed25519.
        Returns:
        Return true if the conversion was successful.
      • convertSecretKeyEd25519ToCurve25519

        boolean convertSecretKeyEd25519ToCurve25519​(byte[] curve,
                                                    byte[] ed)
        Converts a secret ed25519 key to a secret curve25519 key.
        Parameters:
        curve - The array in which the generated key will be placed.
        ed - The secret key in ed25519.
        Returns:
        Return true if the conversion was successful.
      • cryptoSignEd25519SkToSeed

        boolean cryptoSignEd25519SkToSeed​(byte[] seed,
                                          byte[] ed)
        Extracts the seed value from a secret ed25519 key.
        Parameters:
        seed - The array in which the seed value will be placed. Must be Sign.ED25519_SEEDBYTES bytes long.
        ed - The secret key in ed25519.
        Returns:
        Return true if the seed is extracted.
      • cryptoSignEd25519SkToPk

        boolean cryptoSignEd25519SkToPk​(byte[] publicKey,
                                        byte[] ed)
        Extracts the ed25519 public key from a secret ed25519 key.
        Parameters:
        publicKey - The array in which the public key will be placed. Must be Sign.PUBLICKEYBYTES bytes long.
        ed - The secret key in ed25519.
        Returns:
        Return true if the public key is extracted.