Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions features/policies/examples/access-control.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,20 @@ This policy can be used to say, only passkeys are allowed to sign transactions a
"condition": "activity.action == 'EXPORT' && wallet_account.address == '<WALLET_ACCOUNT_ADDRESS>'"
}
```

#### Allow exporting only wallet accounts under a hardened derivation subtree

This policy allows exporting only wallet accounts whose derivation path is a fully-hardened,
4-segment path of the form `m/8797555'/x'/3'/y'` (a Spark-purpose subtree). Because single-quoted
policy literals cannot contain `'` (apostrophe), the path is matched structurally via
`wallet_account.path_indexes` and `wallet_account.path_hardened` rather than as a string. Note that
policies match the literal stored path; on ed25519, soft and hardened spellings derive the same key.

```json JSON
{
"policyName": "Allow exporting only accounts under m/8797555'/x'/3'/y'",
"effect": "EFFECT_ALLOW",
"consensus": "approvers.any(user, user.id == '<USER_ID>')",
"condition": "activity.kind == 'EXPORT_WALLET_ACCOUNT' && wallet_account.path_indexes.count() == 4 && wallet_account.path_indexes[0] == 8797555 && wallet_account.path_indexes[2] == 3 && wallet_account.path_hardened.all(h, h == true)"
}
```
15 changes: 15 additions & 0 deletions features/policies/language.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ The language is strongly typed which makes policies easy to author and maintain.
| | exported | bool | Boolean indicating whether or not this wallet has been exported |
| | label | string | The label of this wallet |
| **Wallet Account** | address | string | The wallet account address |
| | path | string | The account's BIP32 derivation path as stored, e.g. `m/44'/60'/0'/0/0` |
| | path_indexes | list\<int\> | The derivation path child indexes with the hardened bit stripped, e.g. `[44, 60, 0, 0, 0]` |
| | path_hardened | list\<bool\> | Positionally paired with `path_indexes`; true where the corresponding path segment is hardened |
| | wallet_id | string | The identifier of the wallet this account belongs to |
| | curve | string | The curve enum name, e.g. `CURVE_SECP256K1` |
| | address_format | string | The address format enum name, e.g. `ADDRESS_FORMAT_COMPRESSED` |
| **PrivateKey** | id | string | The identifier of the private key |
| | tags | list\<string\> | The collection of tags for the private key |
| | imported | bool | Boolean indicating whether or not this private key has been imported |
Expand Down Expand Up @@ -179,6 +185,15 @@ The language is strongly typed which makes policies easy to author and maintain.
Primitives section.{" "}
</Note>

<Note>
{" "}
Single-quoted policy string literals cannot contain `'` (apostrophe), so derivation paths like
`m/44'/60'/0'/0/0` cannot be matched as strings. This is why the Wallet Account derivation path
is exposed structurally via `path_indexes` and `path_hardened` in addition to `path`. The
`path`, `path_indexes`, `path_hardened`, `wallet_id`, `curve`, and `address_format` fields are
currently populated only for `EXPORT_WALLET_ACCOUNT` activities; other activities will follow.{" "}
</Note>

#### Nested structs

| Struct | Field | Type | Description |
Expand Down