INNER CODE UNIT · Kotlin

sign

terl/lazysodium-java · sample-app/src/main/kotlin/Main.kt:45

    private fun sign() {
        printSection("Running sign detached")
        val msg = "This message needs to be signed"
        val kp: KeyPair = lazySodium.cryptoSignKeypair()
        val pk: Key = kp.publicKey
        val sk: Key = kp.secretKey
        if (!lazySodium.cryptoSignKeypair(pk.asBytes, sk.asBytes)) {
            throw SodiumException("Could not generate a signing keypair.")
        }
        printStep(
            "1",
            "Signing a message",
            "We will be using the random secret key '" + sk.asHexString.toString() + "' and will be " +
                    "signing the message '" + msg + "'."
        )
        val messageBytes: ByteArray = lazySodium.bytes(msg)
        val skBytes: ByteArray = sk.asBytes
        val signatureBytes = ByteArray(Sign.BYTES)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…