Skip to content

fix(sdk): rs-sdk-ffi key helper can return a limited key for a data contract create or update #5963

Open

Description

@Claudius-Maginificent

TL;DR: The iOS/C SDK's "pick a signing key for this transition" helper can return a key with a budget or an expiry for a data contract create or update, which Platform refuses since protocol version 15.

User story

As an app developer using the C/Swift SDK, I want the SDK's key-selection helper to return only a key Platform will accept for a data contract create or update, to get a clear "no suitable key" answer instead of a network refusal after signing.

Scenario

Base flow

An identity's only HIGH/CRITICAL AUTHENTICATION key carries a budget or an expiry. The app calls dash_sdk_identity_get_signing_key_for_transition with DataContractCreate or DataContractUpdate and signs with the returned key on a protocol version 15 network.

Actual behavior

The helper prefers a key without limits but falls back to a limited key (.unwrap_or(matching_keys[0]) in packages/rs-sdk-ffi/src/identity/keys.rs, around line 98). Platform refuses the signed transition with PublicKeyWithLimitsCannotSignDataContractTransitionError (20018).

Expected behavior

For data contract create and update, at protocol versions where consensus refuses limited keys (validate_state_transition_identity_signed v2, protocol version 15), the helper skips keys with limits and returns its "no suitable key" error when nothing else qualifies. Other transition types keep the current fallback.

Detailed discussion

  • The helper takes no protocol version today, so it needs one (from the SDK handle or an argument) to apply the rule only where consensus does.
  • The rule is dpp's IdentityPublicKey::has_limits() (budget or expiry), the same predicate drive-abci's v2 validator uses.
  • No Swift or Kotlin caller of this helper was found in the repository, so impact is limited to external users of the C API.

Prior work

Attribution

🤖 Co-authored by Claudius the Magnificent AI Agent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions