sui
sui copied to clipboard
crypto: Sign with intent in wallet and keystore
-
Previously, signer commits a signature to a BCS serialized
TransactionData
with TYPE_TAG. -
This change means, signer commits to a signature on
IntentMessage<TransactionData>
, which contains three bytes of intent (version, chain_id, scope) AND the BCS serializedTransactionData
without type. This is because the type itself can be inferred fromIntentScope
byte. -
Wallet is gated with RPC API version. Signs with intent only on version >= 0.14.0 (subject to change depends on when we deploy intent signing for sui).
-
This PR only touches user signatures committing to
IntentMessage<TransactionData>
, this does not include AuthoritySignatures committing to other IntentMessage<T> types. -
keystore.sign() is now deprecated in favor of
sign_secure
.
Next Steps
- Note the Wallet release for this change needs to happen before Sui release.
- Use actual chain_id, version_id when we can call RPC endpoint for chain_id instead of hardcoding it in the wallet and keystore.
- Currently validators do not check if intent == expected intent, only checks if the signature commits to an IntentMessage. Add support to validate on intent.
Test Plan
- e2e test from wallet serializes and sign data, verifies by local validators successfully.
- CLI serializes data with intent and submitting the signature to local validators executed transaction successfully.
- Tested against artifact: https://github.com/MystenLabs/sui/actions/runs/3361617096#artifacts
target/debug/sui client transfer-sui --amount 10 --gas-budget 1000 --sui-coin-object-id 0x38c062e1cd88fa97c69cc2d498aaa4d3b366066e --to 0x581a119a6576d3b502b5dc47c5de497b774e68ca
----- Certificate ----
Transaction Hash: D1gA05BQybIR/UX0jCyFqE5a+Wj6wRuQeqhMhWx9D4M=
Transaction Signature: AA==@oJurKmAbfmMsjiGL1ex1k463/+wYZwnD6Q+xjBXeqjYTcIOdM6kHygq9zlt/qoVRBzOUiSQBbDnS9y3MrNG8DQ==@rJzjxQ+FCK9m8YDU8Dq1Yx931HkIArhcw33kUPL9P8c=
Signed Authorities Bitmap: RoaringBitmap<[0, 1, 3]>
Transaction Kind : Transfer SUI
Recipient : 0x581a119a6576d3b502b5dc47c5de497b774e68ca
Amount: 10
----- Transaction Effects ----
Status : Success
Created Objects:
- ID: 0x97078393dae37ff73614cb5aeabb4364500d55c1 , Owner: Account Address ( 0x581a119a6576d3b502b5dc47c5de497b774e68ca )
Mutated Objects:
- ID: 0x38c062e1cd88fa97c69cc2d498aaa4d3b366066e , Owner: Account Address ( 0x581a119a6576d3b502b5dc47c5de497b774e68ca )
Logs in validator
2022-10-20T16:25:36.436619Z INFO node{name=0x77878e5863711cf66cecae32e6d061755022288a}: sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
2022-10-20T16:25:36.436768Z INFO node{name=0x49a81aee4d0c08d867d9bd88565ddc71d74a81b3}: sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
2022-10-20T16:25:36.436919Z INFO node{name=0x3b666d24a57e50efaaa3ea66865100cb72825dfd}: sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
2022-10-20T16:25:36.437597Z INFO node{name=0x2c7f8bc7d9042c3a4965a02c783f48792089fefc}: sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
2022-10-20T16:25:36.438786Z INFO sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
2022-10-20T16:25:36.440239Z INFO sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
2022-10-20T16:25:36.440396Z INFO sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
2022-10-20T16:25:36.441637Z INFO sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
2022-10-20T16:25:36.441871Z INFO sui_types::messages: Received intent Intent { version: V0, chain_id: Testing, scope: TransactionData }
💳 Wallet Extension has been built, you can download the packaged extension here: https://github.com/MystenLabs/sui/actions/runs/3393468248#artifacts
⚠️ 🦋 Changesets Warning: This PR has changes to public npm packages, but does not contain a changeset. You can create a changeset easily by running pnpm changeset
, and following the prompts. If your change does not need a changeset (e.g. a documentation-only change), you can ignore this message. This warning will be removed when a changeset is added to this pull request.
will open a new diff since things had changed quite a bit since last PR