Closed boumba100 closed 2 years ago
Calling GetContributionChallenge for all revealed proof messages should not throw an error.
The function throws the following error:\ panic: runtime error: makeslice: cap out of range
panic: runtime error: makeslice: cap out of range
In the test file, replace proofMsgs with the following
proofMsgs := []common.ProofMessage{ &common.RevealedMessage{ Message: msgs[0], }, &common.RevealedMessage{ Message: msgs[1], }, &common.RevealedMessage{ Message: msgs[2], }, &common.RevealedMessage{ Message: msgs[3], }, }
and replace the revealedMsgs with
revealedMsgs := map[int]curves.Scalar{ 0: msgs[0], 1: msgs[1], 2: msgs[2], 3: msgs[3], }
The following expression calculates an expected array capacity that is smaller than the length of proof2Points and proof2Scalars.
Replace pts := 2 + generators.length - len(revealedMessages) with pts := 3 + generators.length - len(revealedMessages)
pts := 2 + generators.length - len(revealedMessages)
pts := 3 + generators.length - len(revealedMessages)
Replace 2 with 3 since the affected arrays have a minimum length of 3.
2
3
Good catch. Looks like you already submitted a PR. Will review.
Expected Behaviour
Calling GetContributionChallenge for all revealed proof messages should not throw an error.
Actual Behaviour
The function throws the following error:\
panic: runtime error: makeslice: cap out of range
Steps to Reproduce the Problem
In the test file, replace proofMsgs with the following
and replace the revealedMsgs with
Issue
The following expression calculates an expected array capacity that is smaller than the length of proof2Points and proof2Scalars.
Suggested Fix
Replace
pts := 2 + generators.length - len(revealedMessages)
withpts := 3 + generators.length - len(revealedMessages)
Replace
2
with3
since the affected arrays have a minimum length of 3.