Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MPC Contract Signature Arguments #65

Merged
merged 9 commits into from
Jul 27, 2024
Merged

Conversation

bh2smith
Copy link
Collaborator

@bh2smith bh2smith commented May 31, 2024

The Near MPC Contract was recently updated (the whole interface has been modified) - specifically the arguments for the sign method: See here near/mpc#613

This contract is deployed to: https://testnet.nearblocks.io/address/v1.signer-prod.testnet

In this transaction: https://testnet.nearblocks.io/txns/E2fQfcdqPARCnok7RFAJ6WXur3SDKEB7ESgYiH5zHfBT

This PR

  1. Adopts the new MPC contract sign method interface.
  2. Lowers the default gas limit on the signature request (cf Lowered the minimum gas limit and upped the depth near/mpc#589)
  3. Introduces a deposit of 1 YOCTO as is now required.
  4. Updates the kdf (key derivation) to use sha3 instead of sha2 as outlined in https://github.com/near/mpc/blob/develop/CHANGELOG.md
  5. Payloads are now all big endian instead of little endian (so no longer need to be reversed).

Note that the recovery ID is now returned with the MPC Signature, so we can remove A LOT of fluff related to signature "Recovery". There may still be more fluff that can be removed (or perhaps some may need to be reintroduced). Unfortunately the availability of the signing service is not stable enough to test everything. However, we have seen a successful request already: https://sepolia.etherscan.io/tx/0x1adfbaa3151ebdd69b790da41e719eaa039861bd7f56e34fd9f280bded63f535

This change is "breaking" in the sense that the MPC contract interface no longer accets the old Near Tx Payload. This means that the project will no longer work for users pointing at the v2.multichain-mpc.testnet as it does not appear to have been updated along with v1.signer-prod.testnet which we use by default here.

@bh2smith bh2smith force-pushed the hotfix/new-sign-args branch from 61c5ccf to b934bfb Compare June 12, 2024 21:18
@bh2smith bh2smith force-pushed the hotfix/new-sign-args branch from b934bfb to 6f6e5a4 Compare July 2, 2024 12:01
@DavidM-D
Copy link

DavidM-D commented Jul 23, 2024

This won't work with the V5 contract or the mainnet contract. Here's the full changelog for the v5 contract.
Broadly, don't reverse the hash scalar any more, don't reverse the key derivation scalar and use sha3 instead of sha2 for the key derivation. Happy to review, or we'll do it later this week on our libs.

@bh2smith bh2smith force-pushed the hotfix/new-sign-args branch from 543f6b7 to a3c90d1 Compare July 23, 2024 16:23
@bh2smith
Copy link
Collaborator Author

Well that was a nightmare. BUT I GOT IT!

@bh2smith bh2smith requested review from microchipgnu and tifrel and removed request for microchipgnu July 24, 2024 12:22
@bh2smith bh2smith merged commit 0920b7a into main Jul 27, 2024
1 check passed
@bh2smith bh2smith deleted the hotfix/new-sign-args branch July 27, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants