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

PubKey Post-0.40 Cleanup Effort #7357

Open
3 of 11 tasks
amaury1093 opened this issue Sep 22, 2020 · 8 comments
Open
3 of 11 tasks

PubKey Post-0.40 Cleanup Effort #7357

amaury1093 opened this issue Sep 22, 2020 · 8 comments
Labels
C:Crypto T:tech debt Tech debt that should be cleaned up Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.

Comments

@amaury1093
Copy link
Contributor

amaury1093 commented Sep 22, 2020

Summary

The PubKey refactor that has been going on for 0.40 left some follow-up work to be cleaned up.

Problem Definition

#6886 (comment) was the fastest way to get Any PubKeys working for 0.40. However, there are some clean-ups tasks to be done.

Proposal

This are small bits that we discussed in issues, PRs, offline chats. Putting them here so we're able to track them.

cc @blushi Feel free to add more items that you can think of.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@amaury1093 amaury1093 added the Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity. label Sep 22, 2020
@clevinson clevinson added this to the v0.40.1 milestone Sep 24, 2020
@blushi blushi self-assigned this Sep 25, 2020
@robert-zaremba
Copy link
Collaborator

robert-zaremba commented Nov 3, 2020

I updated the issue to provide more details about tendermint.PubKey interface. In general it's good to compose interfaces if possible. Possible means that we agree with method interface. And it's usually better to have that compatibility.

Here the issue is message serialization.

While updating the description and describing the problem of VerifySignature method interface, I reflected a new idea.

Using concrete types for signature verification

I like the simplicity of the tendermints' interface: VerifySignature(msg []byte, sig []byte) bool. In fact this is how I think about signature verification: here are the bytes, and here is the signature for the bytes. This is exactly what I'm also thinking when signing something: only bytes and a public key.

In the OP, we propose a functional argument, which must be a closure:

type GetSignBytesFunc func(mode signing.SignMode) ([]byte, error)

This function doesn't take a message to serialize it. It must have it in it's context. So, the VerifySignature here expects a message / bytes extractor function.

Instead, maybe we can store the signing.SignMode logic in a concrete types, or a wrapper, and use standard the io.Reader interface?

Or maybe we can have a wrapper, and always call it before calling VerifySignature and be compatible with the tendermint interface?

VerifySignature(objWithEmbeddedCodecKnowledge.GetBytes(mode), sig)

@amaury1093
Copy link
Contributor Author

amaury1093 commented Nov 9, 2020

Apart from ed25519, secp256k1, the sdk has another privkey type:

// PrivKeyLedgerSecp256k1 implements PrivKey, calling the ledger nano we
// cache the PubKey from the first call to use it later.
PrivKeyLedgerSecp256k1 struct {
// CachedPubKey should be private, but we want to encode it via
// go-amino so we can view the address later, even without having the
// ledger attached.
CachedPubKey tmcrypto.PubKey
Path hd.BIP44Params
}

It's the same as secp256k1, except that the privkey takes a path struct inside of bytes. Does it make sense to convert this one to a proto.Message too?

I would say yes, just wanted to make sure no-one is objecting.

@robert-zaremba
Copy link
Collaborator

It's the same as secp256k1, except that the privkey takes a path struct inside of bytes. Does it make sense to convert this one to a proto.Message too?

There is a separate task for that: #7718 -- I was already looking at it.
It's better to do it in that task I would say.

@robert-zaremba
Copy link
Collaborator

BTW, why this file is in crypto/ledger package?

@amaury1093
Copy link
Contributor Author

amaury1093 commented Nov 9, 2020

BTW, why this file is in crypto/ledger package?

This file contains a struct representing the private key from a ledger hw wallet.

If we add convert it to proto, I suppose we can put it in crypto/keys/ledger/secp256k1.

@clevinson
Copy link
Contributor

I think the next step here would be forming a WG (maybe just 1-2 people even) for tackling this together with any desired upgrades to TxBuilder & TxFactory?

I don't think its super high priority, but this is what imo the next steps would be.

@educlerici-zondax
Copy link
Contributor

this will be on hold until the implementation of ADR071 is completed.
After that, we can assess the possibility of applying these changes.

@educlerici-zondax
Copy link
Contributor

This issue will continue open until the implementation of the Cryptoprovider can be finished as explained in this PR #18824 and working on this Repo https://github.com/cosmos/crypto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:Crypto T:tech debt Tech debt that should be cleaned up Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Projects
None yet
Development

No branches or pull requests

8 participants