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

Create unit-test for parse public key and assert correct behavior #225

Closed
4 tasks
iramiller opened this issue Apr 7, 2021 · 1 comment · Fixed by #230
Closed
4 tasks

Create unit-test for parse public key and assert correct behavior #225

iramiller opened this issue Apr 7, 2021 · 1 comment · Fixed by #230
Assignees
Labels
bug Something isn't working metadata Metadata Module
Milestone

Comments

@iramiller
Copy link
Member

iramiller commented Apr 7, 2021

Summary of Bug

Parse public key appears to incorrectly handle public keys (observed behavior: empty addresses) when used by memorialize contract

Version

v1.0.0-HEAD

Steps to Reproduce/Remediation

During testing of P8e client integration using Memorialize contract it seems that the parse public key method is not behaving as expected. Create a unit-test for this method and ensure it correctly handles both 33 byte (compressed) and 64 byte (uncompressed) secp256k1 keys.

func parsePublicKey(data []byte) (tmcrypt.PubKey, sdk.AccAddress, error) {
// Parse the secp256k1 public key.
pk, err := btcec.ParsePubKey(data, btcec.S256())
if err != nil {
return nil, nil, err
}
// Create tendermint public key type and return with address.
tmKey := tmcurve.PubKey{} // PubKeySecp256k1{}
copy(tmKey[:], pk.SerializeCompressed())
return tmKey, tmKey.Address().Bytes(), nil
}

Appropriate test case public key values:

// TODO @piercetrey-figure will supply these test case values
comp := ''"
uncomp := ""

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@iramiller iramiller added bug Something isn't working metadata Metadata Module labels Apr 7, 2021
@iramiller iramiller added this to the 1.1.0 milestone Apr 7, 2021
@channa-figure channa-figure self-assigned this Apr 7, 2021
@piercetrey-figure
Copy link

here are the uncompressed/compressed base64-encoded forms of a secp256k1 public key

uncompressed: BGxX6eJRAdXlU64APi95Al44m1FJVgfHlrTpXAqUAB+8JNhM0HgIGWElKbgD6K0KOX9HTJZdlX0z3WTmQrdW+8Q
compressed: AmxX6eJRAdXlU64APi95Al44m1FJVgfHlrTpXAqUAB+8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working metadata Metadata Module
Projects
Development

Successfully merging a pull request may close this issue.

3 participants