Direct Integration with Bitcoin

These are excellent questions, let me try to answer them.
The Bitcoin API will provide means for querying the UTXO set for specific addresses and for submitting transactions. Then there will be the threshold ECDSA API with methods for obtaining the canister’s public key and signing.
That is, there is indeed some processing to be performed by the canister (e.g., through a library).
We want to offer a library for both Rust and Motoko. Rust is easier as we can build upon a large body of open source libraries. Motoko is more challenging as we need to implement quite some huge chunks of logic ourselves. For this reason we have been thinking of asking the community for help with the Motoko library. That has been on my plate for some time now and your question is an excellent trigger for this.

Some of the larger items we need for the library are the following:

  • SHA-512: There is a SHA256 implementation that can be used as a basis, this should be quick for someone who knows this well
  • RIPEMD-160 (for address computation)
  • Elliptic curve scalar multiplication on the secp256k1 curve (for BIP-32 key derivation)
  • Bitcoin address derivation
  • BIP-32 unhardened derivation function
  • Offering high-level API based on the system APIs

Some of those items are required for computing Bitcoin addresses from public keys and for BIP-32 key derivation. The main problem is that Motoko currently has no FFI to reuse those things from implementations in different languages.

The question now is whether anybody here on this subforum would be interested in helping with those items towards obtaining a Motoko library. If you are interested, please just post here. We would be very happy to work with you on this and provide all the information required to get this done.

6 Likes