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

*: migrate to k1 package #1685

Merged
merged 1 commit into from
Jan 26, 2023
Merged

*: migrate to k1 package #1685

merged 1 commit into from
Jan 26, 2023

Conversation

corverroos
Copy link
Contributor

@corverroos corverroos commented Jan 25, 2023

Migrates uses of ecdsa.P*Key to k1.P*Key and uses of geth/crypto to app/k1util.

category: refactor
ticket: #1626

@@ -109,13 +109,13 @@ func Recover(hash []byte, sig []byte) (*k1.PublicKey, error) {
return nil, errors.New("invalid recovery id", z.Any("id", sig[k1RecIdx]))
}

if sig[k1RecIdx] == 0 || sig[k1RecIdx] == 1 {
sig[k1RecIdx] += compactSigMagicOffset // Make the last byte 27 or 28 since that is required below.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this modified the input argument

var sb strings.Builder
_, _ = sb.WriteString("\n")
_, _ = sb.WriteString("***************** Decoded ENR (see https://enr-viewer.com/ for additional fields) **********************\n")
_, _ = sb.WriteString(fmt.Sprintf("secp256k1 pubkey: %#x\n", pubkeyHex(privKey.PublicKey)))
Copy link
Contributor Author

@corverroos corverroos Jan 25, 2023

Choose a reason for hiding this comment

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

@xenowits this was a bug, you hexed it twice

func GenerateInsecureK1Key(t *testing.T, random io.Reader) *k1.PrivateKey {
t.Helper()

k, err := ecdsa.GenerateKey(k1.S256(), random)

Check failure

Code scanning / CodeQL

Use of insufficient randomness as the key of a cryptographic algorithm

This cryptographic algorithm depends on a [random number](1) generated with a cryptographically weak RNG.
@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Base: 54.29% // Head: 54.54% // Increases project coverage by +0.25% 🎉

Coverage data is based on head (b428cab) compared to base (ef2ee39).
Patch coverage: 63.01% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1685      +/-   ##
==========================================
+ Coverage   54.29%   54.54%   +0.25%     
==========================================
  Files         159      159              
  Lines       20627    20609      -18     
==========================================
+ Hits        11199    11241      +42     
+ Misses       7929     7872      -57     
+ Partials     1499     1496       -3     
Impacted Files Coverage Δ
app/app.go 63.06% <0.00%> (-0.73%) ⬇️
cmd/enr.go 8.16% <0.00%> (-6.94%) ⬇️
core/consensus/transport.go 64.58% <ø> (ø)
core/priority/component.go 0.00% <0.00%> (ø)
p2p/k1.go 0.00% <0.00%> (ø)
testutil/compose/define.go 37.97% <40.00%> (-1.25%) ⬇️
eth2util/enr/enr.go 71.42% <66.66%> (-1.10%) ⬇️
p2p/peer.go 29.87% <80.00%> (+0.65%) ⬆️
core/consensus/msg.go 53.27% <83.33%> (-1.13%) ⬇️
app/k1util/k1util.go 29.26% <100.00%> (ø)
... and 16 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

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.

LGTM

@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label Jan 26, 2023
@obol-bulldozer obol-bulldozer bot merged commit 3b79fbc into main Jan 26, 2023
@obol-bulldozer obol-bulldozer bot deleted the corver/migratek1 branch January 26, 2023 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants