Skip to content

ecc/goldilocks: reject trailing data when decoding a point - #707

Open
dxbjavid wants to merge 3 commits into
cloudflare:mainfrom
dxbjavid:goldilocks-point-trailing-data
Open

dxbjavid wants to merge 3 commits into
cloudflare:mainfrom
dxbjavid:goldilocks-point-trailing-data

Conversation

@dxbjavid

@dxbjavid dxbjavid commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

goldilocks.FromBytes, and Point.UnmarshalBinary which delegates to it, only required the input to be at least fp.Size+1 bytes, so any trailing bytes after a 57-byte point encoding were quietly ignored and a given point could then be decoded from more than one byte string. MarshalBinary only ever emits exactly fp.Size+1 bytes, and the same trailing-data laxity has already been tightened for the group elements, the bls12381 G1/G2 points, dleq proofs and ml-dsa signatures, so it seemed worth making the length check here exact as well rather than a lower bound. I've added a small regression test next to the existing canonical-encoding checks.


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@bwesterb

bwesterb commented Oct 5, 2026

Copy link
Copy Markdown
Member

No need for the test. Add comment along the lines of "previous versions accepted trailing data" to help anyone that relied on it.

@dxbjavid
dxbjavid force-pushed the goldilocks-point-trailing-data branch from dfebe5d to 317278c Compare October 5, 2026 19:17
@dxbjavid

dxbjavid commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

makes sense, dropped the test and added a short comment at the length check noting that previous versions accepted trailing data.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 0 new potential issues.

Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants