Package com.goterl.lazysodium.interfaces
Interface Sign.Native
- All Known Implementing Classes:
LazySodium,LazySodiumJava
- Enclosing interface:
- Sign
public static interface Sign.Native
-
Method Summary
Modifier and TypeMethodDescriptionbooleanconvertPublicKeyEd25519ToCurve25519(byte[] curve, byte[] ed) Converts a public ed25519 key to a public curve25519 key.booleanconvertSecretKeyEd25519ToCurve25519(byte[] curve, byte[] ed) Converts a secret ed25519 key to a secret curve25519 key.booleancryptoSign(byte[] signedMessage, byte[] message, int messageLen, byte[] secretKey) Sign a message.booleancryptoSignDetached(byte[] signature, byte[] message, int messageLen, byte[] secretKey) Returns a signature for a message.booleancryptoSignEd25519SkToPk(byte[] publicKey, byte[] ed) Extracts the ed25519 public key from a secret ed25519 key.booleancryptoSignEd25519SkToSeed(byte[] seed, byte[] ed) Extracts the seed value from a secret ed25519 key.booleancryptoSignFinalCreate(Sign.StateCryptoSign state, byte[] sig, byte[] sk) This function computes a signature for the previously supplied message, using the secret key sk and puts it into sig.booleancryptoSignFinalVerify(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.booleanUseful for signing a multi-part message (Ed25519ph).booleancryptoSignKeypair(byte[] publicKey, byte[] secretKey) Generate a signing keypair (ed25519).booleancryptoSignOpen(byte[] message, byte[] signedMessage, int signedMessageLen, byte[] publicKey) Verify a signed message.booleancryptoSignSeedKeypair(byte[] publicKey, byte[] secretKey, byte[] seed) Deterministically generate a public and secret key.booleancryptoSignUpdate(Sign.StateCryptoSign state, byte[] chunk, int chunkLength) Add a new chunk of length chunkLen bytes to the message that will eventually be signed.booleancryptoSignVerifyDetached(byte[] signature, byte[] message, int messageLen, byte[] publicKey) Verifies thatsignatureis valid for themessage.
-
Method Details
-
cryptoSignInit
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
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
This function computes a signature for the previously supplied message, using the secret key sk and puts it into sig.- Parameters:
state- The state.sig- Resultant signature.sk- Secret key.- Returns:
- True if successfully signed completely.
-
cryptoSignFinalVerify
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, int messageLen, byte[] secretKey) Sign a message.- Parameters:
signedMessage- Signed message will be placed here. It isSign.BYTES+messageLenlong.message- The message.messageLen- The message length.secretKey- The secret key.- Returns:
- True if successfully signed.
-
cryptoSignOpen
boolean cryptoSignOpen(byte[] message, byte[] signedMessage, int 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, int messageLen, byte[] secretKey) Returns a signature for a message. This does not prepend the signature to the message. SeecryptoSign(byte[], byte[], int, 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 thatsignatureis valid for themessage.- 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:
-
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.
-