rust-bitcoin / rust-secp256k1

Rust language bindings for Bitcoin secp256k1 library.
Creative Commons Zero v1.0 Universal
345 stars 264 forks source link

ESP32C3 RISCV Support #654

Open 448-OG opened 1 year ago

448-OG commented 1 year ago

Hi!

I am try to use secpk2561 library on RISCV ESP32C3 board and I keep getting this error and then the board just disconnects. The issue is whenever let secp = Secp256k1::new(); is called like in the board below:

    use secp256k1::hashes::sha256;
    use secp256k1::rand::rngs::OsRng;
    use secp256k1::{Message, Secp256k1};

    let secp = Secp256k1::new();
    let (secret_key, public_key) = secp.generate_keypair(&mut OsRng);
    let message = Message::from_hashed_data::<sha256::Hash>("Hello World!".as_bytes());

    let sig = secp.sign_ecdsa(&message, &secret_key);
    assert!(secp.verify_ecdsa(&message, &sig, &public_key).is_ok());

Here is the error I am getting - https://gist.github.com/448-OG/9fd2ad60c535da95c5cec444c4a2b153 If I use the rust k256 crate to try and do this it works fine, so I am guessing it is somewhere in the FFI for secp256k1 but I need some some help

apoelstra commented 1 year ago

Which version of rust-secp256k1 are you using?

Have you made any modifications to the library (e.g. to change or remove the C code we're binding to)?

Are you able to measure how much memory is being allocated? Can you try enabling the lowmemory feature on rust-secp?

448-OG commented 1 year ago

My current dependencies are

secp256k1 = { version = "0.27.0", features = [
    "lowmemory",
    "bitcoin-hashes",
    "rand-std",
] }
rand = "0.8.5"
Kixunil commented 1 year ago

Can you attach any debugger to it? Try stepping through new until something breaks?

448-OG commented 1 year ago

Let me try that I will get back to you