verifyApp
Whether signature is this key's signApp signature over message under context. false, never a throw, for a signature that is not, as with DidKey.verify.
Unlike DidKey.verify, it does throw IllegalArgumentException on a context signApp refuses, so a verifier that takes the context off the wire must check it first.
Throws
when this platform's cryptographic provider cannot run here.
Samples
// This device's key. A real app gets it from a key store, so it is the same key tomorrow.
val key = DeviceKey.generate()
// The app signs its own bytes under a context naming what they are for; anyone holding only the
// device's public name can check the signature.
val move = "move 12: e4".encodeToByteArray()
val signature = key.signApp("chess/move", move)
check(key.id.verifyApp("chess/move", move, signature))
// A signature proves this key, this context and this message, nothing else.
val someoneElse = DeviceKey.generate()
check(!someoneElse.id.verifyApp("chess/move", move, signature))
check(!key.id.verifyApp("chess/resign", move, signature))
check(!key.id.verifyApp("chess/move", "move 12: d4".encodeToByteArray(), signature))
// "kuilt" is kuilt's own context, so no app signature can pass for one of its statements.
val refused = try {
key.signApp("kuilt/admit-proof", move)
false
} catch (_: IllegalArgumentException) {
true
}
check(refused)Content copied to clipboard