bitcoinfuzz icon indicating copy to clipboard operation
bitcoinfuzz copied to clipboard

Add Eclair support to invoice_deserialization target

Open erickcestari opened this issue 9 months ago • 11 comments

We need to integrate Eclair’s BOLT11 invoice parsing into our existing invoice_deserialization target. Unlike other Lightning implementations, Eclair is written in Scala and runs on the JVM, introducing unique challenges for integration.

erickcestari avatar Mar 12 '25 19:03 erickcestari

Hi @erickcestari , can I work on the issue? From Summer of Bitcoin

Lymah123 avatar Mar 24 '25 21:03 Lymah123

Hi @erickcestari , can I work on the issue? From Summer of Bitcoin

Hi @Lymah123, yes, feel free to take this on! Just a heads-up that this might be a bit challenging if you're looking for a good first issue. Let me know if you need any guidance along the way!

erickcestari avatar Mar 25 '25 12:03 erickcestari

I agree with @erickcestari. Go ahead, @Lymah123. However, I believe we could discuss the approach here first before you implement it, this way we can avoid waste of time (especially yours).

brunoerg avatar Mar 25 '25 12:03 brunoerg

Thank you, @erickcestari and @brunoerg. I will send over my approach and seek your insights before implementing anything.

Lymah123 avatar Mar 25 '25 17:03 Lymah123

Objective The task is to enhance the invoice_deserialization target in the existing C++ fuzzing framework (found in driver.cpp) to parse BOLT11 invoices in a way that matches Eclair’s implementation. Since Eclair is Scala-based and runs on the JVM, while our system is C++, we need a strategy to bridge this gap effectively. Current Framework Overview File: driver.cpp contains the Driver class, which manages fuzzing targets.

Target: InvoiceDeserializationTarget processes a buffer, converts it to a string, and calls deserialize_invoice on each loaded module.

Modules: Derived from BaseModule, they implement deserialize_invoice(const std::string&) returning std::optional (success/failure).

Behavior: The target ensures consistency across modules via assertions.

Our integration must fit this modular structure and replicate Eclair’s BOLT11 parsing logic.

Proposed Strategy

After exploring the codebase, I located the inovice_deserialization Target in the driver.cpp file. The target is located in the Driver class and the relevant function is InvoiceDeserializationTarget

Given the language mismatch (Scala vs. C++), here are the viable approaches

  1. Create a Scala object to parse BOLT11 invoices using Eclair.
  2. Compile the Scala code into a JAR file
  3. Create a Java Native I bridge to call the EclairParser.parseInvoice function.
  4. Modify the InvoiceDeserializationTarget function to call the Eclair parser through the JNI bridge.

Hi, @erickcestari and @erickcestari. That is what I was able to come up with after checked the codebase. Looking forward to your responses.

Lymah123 avatar Mar 26 '25 21:03 Lymah123

4. Modify the InvoiceDeserializationTarget function to call the Eclair parser through the JNI bridge

I think it's a good approach. However, you don't need to modify the InvoiceDeserializationTarget function. Instead, you should create a new module in BitcoinFuzz and implement the deserialize_invoice function in module.cpp. This function will then call the Eclair parser via the JNI bridge.

erickcestari avatar Mar 28 '25 13:03 erickcestari

Alright. Thanks for that.

@erickcestari and @brunoerg . Does this mean I can proceed with the implementation? Thank you.

Lymah123 avatar Mar 29 '25 02:03 Lymah123

Alright. Thanks for that.

@erickcestari and @brunoerg . Does this mean I can proceed with the implementation? Thank you.

Yes, you can proceed with the implementation. Let us know if you need any further clarification. Thanks!

erickcestari avatar Mar 31 '25 12:03 erickcestari

Alright. Thanks for that. @erickcestari and @brunoerg . Does this mean I can proceed with the implementation? Thank you.

Yes, you can proceed with the implementation. Let us know if you need any further clarification. Thanks!

Alright, thank you.

Lymah123 avatar Mar 31 '25 22:03 Lymah123

How is going @Lymah123?

brunoerg avatar Apr 08 '25 19:04 brunoerg

Hi @brunoerg , it is going well. I will submit a PR for it this week. Sorry, I was sick that's why. But I am fine now. I already started working on it. Sorry about that.

Lymah123 avatar Apr 08 '25 19:04 Lymah123