Challenge

class Challenge

A host's answer to a device asking to join: "prove you hold your key, and here is proof that I hold mine." The host signs it, so the joiner learns the host's key from the host itself, and the fresh hostNonce it carries is what the joiner's AdmissionProof must sign over.

It names the room, both ends by their peer ids, and both nonces: the joinerNonce the joiner sent in its Hello, so the joiner knows this challenge answers its own Hello and is not a replay, and the hostNonce the host chose, so the proof answering it is good only once.

Its wire form is the signed bytes themselves — the layout below, then the 64-byte signature — and two challenges are equal when their wire bytes are. The arrays it hands out are copies.

Layout tag "kuilt/challenge", version 1, six fields in this order:
host key (33-byte compressed point) ‖ room id (UTF-8) ‖ host peer id (UTF-8) ‖
joiner peer id (UTF-8) ‖ joiner nonce (16 bytes) ‖ host nonce (16 bytes)

decode reads the layout only; it does not check the signature. isSignedByHost does that, under the hostKey the challenge itself names — which proves the challenge came from whoever holds that key, not that the key belongs to anyone in particular.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The key the host signed this with, and claims as its own.

Link copied to clipboard

The nonce the host chose for this challenge, which the joiner's proof signs: a copy.

Link copied to clipboard

The host's peer id on the fabric.

Link copied to clipboard

The nonce the joiner sent in its Hello, echoed back: a copy.

Link copied to clipboard

The joiner's peer id: the fabric sender of the Hello this answers.

Link copied to clipboard

The room the joiner is being admitted to.

Link copied to clipboard

The layout followed by the host's signature: what is sent. A copy.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
suspend fun isSignedByHost(): Boolean

Whether the signature on wire is hostKey's over the layout. false, never a throw, for a bad signature or a hostKey whose point is not on the curve.

suspend fun isSignedByHost(scheme: KeyScheme): Boolean

isSignedByHost, checked in scheme rather than always in KeyScheme.P256. A room passes its own DeviceKeyStore.keyScheme, so a room on the real scheme checks with ECDSA whatever was sent.

Link copied to clipboard
open override fun toString(): String