fix(emulated): pad the input of the inverse hint to NbLimbs - #1855
Open
FlashWayne wants to merge 1 commit into
Open
FlashWayne wants to merge 1 commit into
FlashWayne wants to merge 1 commit into
Conversation
InverseHint requires the value on NbLimbs limbs, but computeInverseHint forwarded the element's limbs as they are. An element stored on fewer limbs, such as a Select between two small constants, made the hint fail with "inputs missing". Pad the input limbs with zeros before calling the hint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Field.Inversefails for a non-constant element that is stored on fewer limbs thanNbLimbs(), for example the result ofSelectbetween two small constants.Div,Mul,SqrtandExpon the same element work.Before:
NewHint: inputs missing(r1cs, scs and the test engine).After: solves, result checked against
ModInverse.computeInverseHintappends the element's limbs as they are, whileInverseHintrequires2 * NbLimbsinputs after the header (modulus, then value).computeDivisionHintpasses the limb counts explicitly, which is why division is not affected. This pads the value with zero limbs incomputeInverseHint, so the hint's input layout is unchanged.Test:
TestInverseShortElement(both branches of the select, test engine + compiled r1cs/scs), fails on master.std/math/emulated,sw_emulatedandinternal/statspass.