I'm looking at the code - does it store the top level values as bipf arrays? https://github.com/arj03/ssb-butt2/blob/master/index.js#L8-L11
layered? because they the content is encoded as a bipf object, but then it looks like it's encoded as a bipf buffer in another array?
Reading the code I spotted several things, that feel "nit picky" to mention and 7 times faster is great anyway, but I'll ask anyway. The main question I have is about how the batch signing works.
it also seems to me that there are micro-optimizations that could add up,
for example, https://github.com/arj03/ssb-butt2/blob/master/index.js#L288
using Object.keys to get an array of the signature keys when
for(var key in signatures) might be faster?
Instead of layering, what about just implementing a non-recursive decode, it would just decode the top layer and return buffers for the values? seems it might achive the same result, while still keeping the whole thing as a single valid bipf object?
The important question: how does batch signing work?
does it keep in memory an array of all signatures? else why is it accessing a signature from an array based on the sequence?
It sounds like you use specially formatted batch signature messages?
I think you could make a much simpler approach: since hashes preserve the uniqueness of the hashed data, it means signing the hash is as good as signing the data, and signing the hash of the hash (or the hash of data containing the hash) is also good enough. So therefore, every ssb message signs not just the message content but the whole chain of preceding messages. If you changed one bit in the first message the hashes of all subsequent messages would change.
So... instead of having a special batch signature - just sign each message like normal and when verifying, queue up N messages, then randomly verify one. then you can write the messages up to the verified one.