OZSmartAccountSignature

public protocol OZSmartAccountSignature : Sendable

Base type for OpenZeppelin smart-account signature variants.

Smart accounts support multiple signature types for transaction authorization:

Each variant converts to the SCValXDR representation expected by the on-chain verifier contract. The shape differs per variant:

  • WebAuthn: SCValXDR.map with alphabetically-ordered keys.
  • Ed25519: SCValXDR.bytes containing the raw 64-byte signature.
  • Policy: SCValXDR.map([]) (empty map).

Example:

let signature = try OZWebAuthnSignature(
    authenticatorData: authenticatorDataBytes,
    clientData: clientDataBytes,
    signature: signatureBytes
)
let scVal = signature.toScVal()
  • Converts this signature to its on-chain SCValXDR representation.

    Construction-time validation may throw SmartAccountValidationException.InvalidInput; this conversion is total (non-throwing).

    Declaration

    Swift

    func toScVal() -> SCValXDR

    Return Value

    The signature encoded as an SCValXDR value. The concrete type depends on the variant (map for WebAuthn/Policy, bytes for Ed25519).

  • Returns the raw bytes content that is stored inside the ScVal::Bytes value of the smart account’s on-chain AuthPayload.signers: Map<Signer, Bytes>.

    The exact content is verifier-dependent:

    • WebAuthn: XDR-encoded WebAuthnSigData contracttype struct. The WebAuthn verifier receives this as sig_data: Bytes and deserializes it to WebAuthnSigData.
    • Ed25519: the raw 64-byte Ed25519 signature with no XDR wrapper. The Ed25519 verifier receives sig_data: BytesN<64> and the host coerces Bytes(64) to BytesN<64> directly. Wrapping in an XDR envelope inflates the content to ~70 bytes, which the coercion rejects with InvalidAction.
    • Policy: XDR-encoded empty map (same byte sequence as toScVal() encoded).

    Throws

    SmartAccountTransactionException.SigningFailed if XDR encoding fails (WebAuthn/Policy).

    Declaration

    Swift

    func toAuthPayloadBytes() throws -> Data