OZSmartAccountSignature
public protocol OZSmartAccountSignature : Sendable
Base type for OpenZeppelin smart-account signature variants.
Smart accounts support multiple signature types for transaction authorization:
OZWebAuthnSignaturefor passkey / biometric authentication signatures.OZEd25519Signaturefor traditional Ed25519 keypair signatures.OZPolicySignatureas a marker for policy-based authorization (an empty map).
Each variant converts to the SCValXDR representation expected by the on-chain
verifier contract. The shape differs per variant:
- WebAuthn:
SCValXDR.mapwith alphabetically-ordered keys. - Ed25519:
SCValXDR.bytescontaining 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
SCValXDRrepresentation.Construction-time validation may throw
SmartAccountValidationException.InvalidInput; this conversion is total (non-throwing).Declaration
Swift
func toScVal() -> SCValXDRReturn Value
The signature encoded as an
SCValXDRvalue. 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::Bytesvalue of the smart account’s on-chainAuthPayload.signers: Map<Signer, Bytes>.The exact content is verifier-dependent:
- WebAuthn: XDR-encoded
WebAuthnSigDatacontracttype struct. The WebAuthn verifier receives this assig_data: Bytesand deserializes it toWebAuthnSigData. - Ed25519: the raw 64-byte Ed25519 signature with no XDR wrapper. The Ed25519
verifier receives
sig_data: BytesN<64>and the host coercesBytes(64)toBytesN<64>directly. Wrapping in an XDR envelope inflates the content to ~70 bytes, which the coercion rejects withInvalidAction. Policy: XDR-encoded empty map (same byte sequence as
toScVal()encoded).
Throws
SmartAccountTransactionException.SigningFailedif XDR encoding fails (WebAuthn/Policy).Declaration
Swift
func toAuthPayloadBytes() throws -> Data - WebAuthn: XDR-encoded
View on GitHub
Install in Dash