sign

abstract suspend fun sign(message: ByteArray): ByteArray

Signs message: ECDSA on P-256 over SHA-256 of message, as the 64-byte raw r ‖ s form that id's DidKey.verify accepts.

An implementation must never reuse a nonce across different messages, since two signatures sharing one give the private key away. Random nonces and deterministic ones (RFC 6979) both meet that, so signing the same message twice may give two signatures or the same one.

An app signs with signApp, not this. kuilt's own statements — the admission proof, the challenge, the grant — are signatures over raw bytes, so an app that signed raw bytes a peer handed it could be made to sign one of them. signApp signs under an app/ prefix no kuilt statement can start with. This member is behind IdentityInternalApi for that reason (#3600).

A key implemented outside kuilt, such as one held in a Secure Enclave, still implements this, and Kotlin asks the override to opt in too. Mark it @IdentityInternalApi, as every key in kuilt does, so a caller holding the concrete type still has to opt in. @OptIn on the override compiles as well, but lifts the gate for that caller.

Throws

when this platform's cryptographic provider cannot sign here.