Foundation-Devices / passport-firmware

Firmware for Passport v1
49 stars 16 forks source link

using libsecp256k1 rather than trezor-crypto? #1

Open apoelstra opened 3 years ago

apoelstra commented 3 years ago

Hi,

I wonder if this project has considered using libsecp256k1 rather than trezor-crypto? libsecp is entirely constant-time, uses no dynamic memory allocations (except when constructing a precomputation context, but you can do this in a fixed slab of memory if you want), has significantly more review cycles than any other cryptography library focused on secp256k1 EC crypto. It is focused purely on Bitcoin and Bitcoin applications and is used by Bitcoin Core.

If there are pain points related to using our library in an embedded context we'd like to hear about them -- over the last 18 months we've fixed a number of issues that had complicated the embedded development story, including making it possible to compile without any libc and simplifying the process of building the library without autotools (although the latter lacks documentation.).

Andrew

FoundationKen commented 3 years ago

Hi Andrew! Thanks for taking the time to look into this.

I'll add this to my list of issues to investigate. A quick look suggests that we could probably replace the few places in the code where we do signing without much trouble (just map the calls through from MicroPython to C).

I'll need to spend some time reviewing the libsecp256k1 code and compare it with trezor to see what else might be possible.

I definitely appreciate you being open to changes to support embedded development (I also saw you were open to improvements for use in embedded/nostd use cases in your Rust library, which is great).

Cheers!

EvanWinget commented 3 years ago

Hey Ken - just wanted to add a user’s perspective on this. I’m more confident in hardware wallets that use libsecp256k1, and I’m assuming that others feel similarly. Bitbox has been using it for 5+ years and coldcard recently adopted it in firmware 4.0.0.

Passport seems like it’s off to a great start and the QR scanning is a huge UX improvement for PSBTs!

FoundationKen commented 3 years ago

Thanks Evan! It’s in our backlog to switch over!

EvanWinget commented 3 years ago

Glad to hear it, Ken! Thanks for the response and the awesome product!

jonathancross commented 2 years ago

@FoundationKen Where can we follow progress on this?