GeezerVison is showing github.com — FAQ: Discrepancy Between Paper and Implementation · Issue #107 · BitVM/BitVM
FAQ: Discrepancy Between Paper and Implementation #107DescriptionHi team,
I noticed that you've implemented several connectors (0..5, a..c, z). However, I'm a bit confused about the discrepancies between the implementation and the paper.
From my understanding, theoretically, each connector corresponds to a spending path of UTXO outputs as described in your paper. For example, connector_c handles the spending path between the assert and disprove transactions, while its taproot_spend_info is a composite of multiple lock_scripts that correspond to the sub-program of the original program f in the paper.
However, the discrepancies I found are as follows:
- There is no optimistic branch spending info in
connector_c. Link
- The number of outputs in the
assert transaction differs from those mentioned in the paper. Link
Could you clarify if there is an alternative approach being taken or provide further details? ActivitylucidLuckylee commented on Oct 5, 2024 Hi!
In the optimistic case connector_c is spendable via the key spend path with the operator's signature (relevant line).
I remember connector_c being a bit of a special case in the implementation because in theory we would have to pre-sign every possible script spend path of connector_c. Thus, one pre-signed disprove transaction per taproot leaf.
By splitting connector_c into two connectors (c and 5) and using SIGHASH_SINGLE we can decouple the covenant and the taproot scripts so only a single version of the disprove transaction has to be pre-signed. whbjzzwjxq commented on Oct 6, 2024 Thanks for your clarification. Thus, the disprove transaction is not signed for each program chunk in the implementation. Instead, a templated disprove transaction is signed by the n-of-n committee. whbjzzwjxq commented on Oct 6, 2024 BTW, I have another question: May I know whether the bridge client is done or is still working in progress? It looks like you haven't implemented the combination with the program chunks and the assert-disprove transactions. lucidLuckylee commented on Oct 6, 2024 We haven't completed the chunking yet whbjzzwjxq commented on Oct 6, 2024
We haven't completed the chunking yet
May I know the reason? Or would you mind clarifying whether I am correct or not:
The premise is that chunks communicate with each other with input and output, requiring storing those items in the witness field of a disprove transaction:
- The desired input and output of the chunk.
- The Winternitz signature of the input and output.
From my observation, chunking is not trivial due to the following reasons:
- We want to keep the accumulated input and output size in all chunks as tiny as possible.
- We want to use the pure stack instead of stack + altstack to communicate.
- The input and output size in each witness is limited.
lucidLuckylee commented on Oct 6, 2024 Number 2 doesn't really matter since we can at the end of a script just pop all items from the altstack and move them to the stack.
Usually the input and output stack of every chunk script should be hashed to reduce the number of inputs required for the Winternitz signatures.
We implemented a prototype for an automatic chunker. However, the stack size gets too large to feasibly hash when we provide the entire input at the start and always pass the entire stack from one chunk to the next chunk. Since the automatic chunker is already quite complex the current consensus among the teams contributing to bitvm is that providing a manual layout for the chunks is achieved more easily and quickly than completing the chunker and adjusting the bitvm codebase to its needs.
Note that hashing is costly so we can realistically only hash up to 1024 bytes or 256 stack elements per input or output. Imo this is the biggest show stopper right now and the reason why piping the entire memory in a linear fashion through the chunks might just not be feasible. The manual layout seems to require some chunks to forward parts of their output to different subsequent chunks. whbjzzwjxq commented on Oct 6, 2024 First of all, I appreciate your time and response. I almost fully understand your implementation and the challenge behind it.
the current consensus among the teams contributing to bitvm is that providing a manual layout for the chunks is achieved more easily and quickly than completing the chunker and adjusting the bitvm codebase to its needs
I agree with this. It seems more practical to implement, especially since a general solution for chunking may not be necessary at this stage.
Imo this is the biggest show stopper right now and the reason why piping the entire memory in a linear fashion through the chunks might just not be feasible
I see your point. That said, I wonder if there might still be some uncertainty about whether the manual layout will work entirely. It’s possible there are still chunks with more than 256 inputs and outputs, or that exceed the 4MB witness limit.
I’ll take some time to think about how we can solve this. Thanks again for sharing your insights. lucidLuckylee commented on Oct 7, 2024 Hello again! I wanted to reiterate on splitting a chunk's output.
Problem
Let there be chunks A, B, C and D that in the overall program are executed in that order. Also let us use m to denote the maximum transferable output and input size for each chunk and assume that it is an even number.
The chunks have the following properties:
- A outputs
m stack elements
- B needs to access the top $\frac{m}{2}$ stack elements of A's output and puts one element on the stack
- C needs to access only B's output so $\frac{m}{2} + 1$ stack elements and removes all of them from the stack
- D needs to access only the bottom $\frac{m}{2}$ stack elements of A's output
If we always pass the entire memory in linear fashion the situation looks like this:
m m + 1 m/2
A ────────> B ────────> C ────────> D
The transition from B to C is, in that case, impossible.
Solution
By splitting the output of A into two size $\frac{m}{2}$ parts that are hashed seperately we can achieve a solution:
m/2 m/2 + 1
┌─────> B ────────> C
│
A ──┤
│
└─────> D
m/2
Note that this increases the number of commitments in the assert transaction.
Of course C could also leave up to $\frac{m}{2}$ elements on the stack making the chunking layout an acyclic digraph.
m/2 m/2 + 1
┌─────> B ────────> C
│ │
A ──┤ │ m/2
│ │
└───────────────────┴───> D
m/2
The current chunker prototype unfortunately only tracks the deepest accessed element on the stack for the scripts. Thus, it is hard to tell when a chunk needs to access only a certain part of the output.
Your symbolic execution engine seems like a good fit to figure out when stack elements are unused until a certain chunk. whbjzzwjxq commented on Oct 8, 2024 It's a dependence analysis problem. We could identify which chunk uses which stack items.
We'd like to explore this idea further.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|