Skip to content
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

fix: add proof size check when the VRF proof is empty #765

Merged
merged 6 commits into from
Mar 15, 2024

Conversation

170210
Copy link
Contributor

@170210 170210 commented Mar 11, 2024

Description

This PR added an error handle in proof size check when the VRF proof is empty.

Previously, we allowed the proof hash to be 0 in Validateproof because there was no proof required when verifying Genesis block's information. However, since there is no Genesis block, the proof hash should not be zero in general verification.

I tested it with finschia-sdk, and there is no problem when this handling was added.

related #510

Signed-off-by: 170210 <j170210@icloud.com>
Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 self-assigned this Mar 11, 2024
@170210 170210 marked this pull request as draft March 11, 2024 06:04
@170210 170210 changed the title Fix/validateproof fix: add proof size check when the VRF proof is empty Mar 11, 2024
Signed-off-by: 170210 <j170210@icloud.com>
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.53%. Comparing base (fc54d22) to head (4a2f67b).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #765      +/-   ##
==========================================
- Coverage   66.58%   66.53%   -0.05%     
==========================================
  Files         285      285              
  Lines       37919    37917       -2     
==========================================
- Hits        25248    25228      -20     
- Misses      10871    10882      +11     
- Partials     1800     1807       +7     
Files Coverage Δ
crypto/ed25519/migration.go 100.00% <100.00%> (+16.66%) ⬆️

... and 17 files with indirect coverage changes

@170210 170210 marked this pull request as ready for review March 11, 2024 09:05
@ulbqb
Copy link
Member

ulbqb commented Mar 11, 2024

// ValidateProof returns an error if the proof is not empty, but its
// size != vrf.ProofSize.
func ValidateProof(h []byte) error {

It looks like empty proofs are admitted intentionally. Would you research this?

@ulbqb ulbqb added the C: enhancement Classification: New feature or its request, or improvement in maintainability of code label Mar 11, 2024
Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 requested a review from Mdaiki0730 March 12, 2024 08:19
crypto/ed25519/migration.go Outdated Show resolved Hide resolved
Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 requested review from ulbqb and 0Tech March 14, 2024 07:46
@ulbqb
Copy link
Member

ulbqb commented Mar 14, 2024

Please add following contents to description:

  • Related PRs
  • Process where you decided to remove empty proof handling (What you tried)
  • The reason where this handling was added

@ulbqb
Copy link
Member

ulbqb commented Mar 14, 2024

| Proof | slice of bytes (`[]byte`) | Proof is a vrf proof | Length of proof must be == 0 or == 80 (curve25519-voi) |

And update spec please.

Signed-off-by: 170210 <j170210@icloud.com>
@170210 170210 merged commit 1279868 into Finschia:main Mar 15, 2024
24 checks passed
@170210 170210 deleted the fix/validateproof branch March 15, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants