-
Notifications
You must be signed in to change notification settings - Fork 550
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
New "packed" random oracle input type #10005
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Legacy
around client-sdk and Rosetta looks good 👍
This reverts commit 53a929f. NOTE: fixing this programmatically from the log involves (from vim) :tabe src/app/replayer/test/archive_db.sql :vsplit ~/Downloads/mina_build_XXXXX_replayer-test.log You can set up a (slow) macro to perform all of the replacements with qq/expected_ledger_hash 2f""ayi"4f""syi"h:%s/a/s/g lq Then, for N the number of replacements, we run N@q and go grab a coffee. This *WILL* lock up your vim instance for some time.
Should this one be closed now #9935 |
When this is merged, the surrounding PRs should be readjusted to avoid it. There's still unmerged code in those 7 other PRs |
Based on the description, it seems like this can have collisions.
I've probably missed something important. |
Indeed it could, except we only use this random oracle input type when the structure of the underlying data is fixed, so it should be a non-issue. Perhaps part of the code review should be confirming that, though? |
Either that or making it safe no matter how it's used. I suspect the reason it's this way is for performance in the snark, so the latter may be too expensive, correct? |
The latter makes the snark more expensive, yes. We should write a variant of this called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge diff!
Checked things carefully for mistakes.
Left a lot of questions and some suggestions.
Approved!
Going back to the encoding of the input, when you say that the underlying data structure is fixed you mean that you would never be using different types of input vectors as part of the same scenario? Meaning, by the context one would be able to know what is the underlying composition of the chunk? Otherwise, one would need some bits of information to differentiate between different "recipes" leading to those chunks. For a shorter example of 32bit chunks, these could either be [u32] or [u16, u16]. When the output domain only has (in this case) 2^32 possible values, in order to avoid collisions, one can only have at most 2^32 different inputs. But given that 32bit chunks can have 2 compositions, one instead would have twice that input domain size, and thus collisions. So if the underlying structured is "assumed" and known a priori, then there seems to be no collisions. |
Correct, yes. We only use poseidon hashing where we need to mirror the hashing within a snark circuit; because the format of the data in the snark circuit is necessarily fixed by the permutation argument, we always know that the data will be laid out in exactly the same way.
Agreed. As the proof system becomes more flexible (and as SnarkyJS becomes more able to use that flexibility) we'll probably want to create a version of this that does the 'safe' thing, but for now I believe it isn't an issue. |
dfd8c2c
to
e1eb5fa
Compare
After some debugging, this PR now increases the amounts in the payment test by 10x, to ensure that block rewards do not cause the balance of the timed account to fall back into the valid range. (cc @QuiteStochastic) |
This PR is based off PR #9935, but refactored to change only the code that relates to random oracle input. In order to compile, this includes changes that were previously scattered across PRs #9933, #9934, #9935, #9936, #9937, #9938, #9939, #9940, with some modifications to separate out the other unrelated changes that were also bundled with them.
This PR takes a slightly different strategy to #9935, by keeping the random oracle inputs (and the signatures derived from them) separated as
Random_oracle.Input.Chunked
andRandom_oracle.Input.Legacy
(equivalentlySchnorr.Chunked
,Schnorr.Legacy
), so that it is clear at every usage which of the two input systems is used.This also makes the requisite changes for the client SDK and for rosetta, ensuring that both continue to use the
Legacy
hashing/signature mode for compatibility purposes. As in the original, 'signed transactions' also use theLegacy
hashing/signature mode, to ensure that various implementations do not need to be updated.The term 'chunk' refers to a number less than the size of a field element, which we treat as an indivisible bitstring and chain together to form field elements by computing
a + b * 2^n + c * 2^(n+m) + ...
. For example, considerThis differs from the original implementation, which decomposed all non-field-element data into bits and recombined those bits back into field elements. This decomposition and recomposition is significantly more expensive than the extra hashing we incur by not doing so.
Checklist: