-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General batch verification API context #1087
Comments
This is a start. Ideally, the batch object does not hold signatures, messages and the likes. Instead, only scalars and points are stored on the batch object's scratch space. In order to avoid allocating space again for scalars and points in We also need to keep in mind that we can not compute the Schnorr batch verification randomizer by hashing all signatures, public keys and messages as before. We just don't know all of them yet when |
@real-or-random pointed out to me that there is a simpler solution at the cost of requiring more memory. What I had assumed above is that we compute the randomizer immediately to allow storing only the sum of scalars that are multiplied with G (c.f. We can do this by having the batch object store a |
Hm yeah, right but then we'll need to store the scalars as you point out, and I'm not sure that's worth the hassle. So we'll anyway need to keep some O(u) things:
Adding On the other hand, if you have enough memory, this argument won't apply. Moreover, the caller may keep the |
Sorry for the delay. I took a look at
Is option1 the right approach? Batch object's Scratch Space Initialization: batch* batch_verify_init(size_t n_terms) {
batch ret;
scratch_size = strauss_scratch_size(n_terms) + STRAUSS_SCRATCH_OBJECT*16;
ret.scratch = scratch_create(&ctx->error_callback, scratch_size);
/* allocate space for n_terms (scalar, points) on scratch space*/ --> implementation info below
/* other necessary batch obj allocations */
return &ret;
} Here, we create scratch memory required for Allocating scratch memory for
/* both of these are impl using scratch_alloc() */
ret.scratch->points = scratch_alloc(n_terms * sizeof(secp256k1_gej));
ret.scratch->scalars = scratch_alloc(n_terms * sizeof(secp256k1_scalar));
ret.scratch->points = scratch_alloc((2*n_terms + 2) * sizeof(secp256k1_ge));
ret.scratch->scalars = scratch_alloc((2*n_terms + 2) * sizeof(secp256k1_scalar)); If we use format1, we can't call |
That's not true if the pippenger algorithm is refactored appropriately. The algorithm would know that Besides, I like the idea that the batch object creates its own scratch space. |
There's another advantage to having a single call instead of a streaming API. In general, developers want to know approximately how long a particular function call takes. With the "streaming" API one can not predict when a call to
If there was a way to do this that allows multiple objects to be batch verified and is extensible this would be worth exploring. I just don't see how. |
context: #760 (comment)
I am trying to implement a PoC for the API proposed above. I have the following
batch_verify
object in mind.I plan to use a scratch object to store the data (schnorrsig or tweaks) since it will allow us to keep on adding new data (using
batch_add_sig
andbatch_add_xpubkey_tweak
) and increase the batch object's size accordingly. This batch object doesn't seem compatible withecmult_pippenger_batch
orecmult_strauss_batch
function call.Since both Pippenger and Strauss takes the arguments:
void *cbdata
--> contains the required datasecp256k1_scratch *scratch
--> newly allocated scratch space where scalars and points are loaded for multi multiplicationBut this batch object already has the required data in a scratch space. Maybe use another scratch space for loading scalars and points? Won't this increase memory usage?
Also, does this API require a new module? Or including these in the
schnorrsig
module suffice?The text was updated successfully, but these errors were encountered: