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

core/validatorapi: fix attestation domain and signature verification #264

Merged
merged 3 commits into from
Mar 22, 2022

Conversation

corverroos
Copy link
Contributor

Fixes issues with signature verification and creation.

  • Sign the HashTreeRoot not the MarshalSSZ.
  • Use the AttestationData target epoch to calculate attestation domain.
  • Add signing unit test copied from prysm
  • Support more overrides in beaconmock http server.
  • Generate valid attestation data in beaconmock.

category: bug
ticket: #251

@codecov
Copy link

codecov bot commented Mar 22, 2022

Codecov Report

Merging #264 (a63486d) into main (db6c6db) will increase coverage by 1.38%.
The diff coverage is 65.00%.

@@            Coverage Diff             @@
##             main     #264      +/-   ##
==========================================
+ Coverage   57.30%   58.68%   +1.38%     
==========================================
  Files          53       53              
  Lines        3904     3957      +53     
==========================================
+ Hits         2237     2322      +85     
+ Misses       1357     1316      -41     
- Partials      310      319       +9     
Impacted Files Coverage Δ
testutil/validatormock/validatormock.go 35.80% <16.66%> (ø)
core/validatorapi/signing.go 37.50% <60.00%> (+1.78%) ⬆️
testutil/beaconmock/options.go 59.22% <66.66%> (+29.61%) ⬆️
core/validatorapi/validatorapi.go 42.16% <75.00%> (ø)
testutil/beaconmock/beaconmock.go 62.85% <100.00%> (+17.14%) ⬆️
testutil/beaconmock/server.go 65.65% <100.00%> (+1.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db6c6db...a63486d. Read the comment docs.

Copy link
Contributor

@dB2510 dB2510 left a comment

Choose a reason for hiding this comment

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

Looks Great!

@@ -124,12 +124,12 @@ func NewSigner(secrets ...*bls_sig.SecretKey) SignFunc {
return eth2p0.BLSSignature{}, err
}

msg, err := data.MarshalSSZ()
msg, err := data.HashTreeRoot()
Copy link
Contributor

Choose a reason for hiding this comment

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

how did you found out that actual msg should be HashTreeRoot not MarshalSSZ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I implemented this tests from prsym.

// TestSignAndVerify signs and verifies the signature.
// Test input and output obtained from prysm/validator/client/attest_test.go#TestSignAttestation.
func TestSignAndVerify(t *testing.T) {

@corverroos corverroos merged commit 67566aa into main Mar 22, 2022
@corverroos corverroos deleted the corver/verifysig branch March 22, 2022 17:54
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.

None yet

2 participants