-
Notifications
You must be signed in to change notification settings - Fork 28
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
Introduce composite key to delegate features to each function key #101
Conversation
4edece2
to
e6d875b
Compare
477d819
to
b6715d4
Compare
crypto/crypto.go
Outdated
Identity PrivKey `json:"identity"` | ||
SignKey PrivKey `json:"sign"` | ||
VrfKey PrivKey `json:"vrf"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need three keys?
As I said in the previous meeting, we're not going to use HSM, so I think we'll only need 2 keys.
And three keys are too many.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed VRF key to be the role of Identity.
crypto/crypto.go
Outdated
func (pk PubKeyComposite) Validate() bool { | ||
msg := b.NewBuffer(pk.SignKey.Bytes()) | ||
msg.Write(pk.VrfKey.Bytes()) | ||
return pk.Identity.VerifyBytes(msg.Bytes(), pk.Seal) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it works well?
Because the msg
to be made with SignKey's PubKey byte and VrfKey's Pubkey byte is difference the msg to be made with SIgnKey's PrivKey bytes and VrfKey's PrivKey bytes.
(SignKey PubKe bytes + VrfKey PubKey bytes) != (SignKey PrivKey bytes + VrfKey PrivKey bytes)
The place to create the msg
to generate the seal
is is https://github.com/line/tendermint/pull/101/files#diff-31c4aa3a4249d4755fc652d3e0087b98R121-R122
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source is out of date, but this part was a bug. Now it doesn't use the seal
(the signature of two-keys) and instead calculates its Address
from the two-keys. Therefore, if one of the keys is tampered with, the address will always change.
I think it's better that |
d2a2bbb
to
9499629
Compare
I was concerned about where to define this Composite key type, but I put it in And there were two reasons for the cyclic import error. One will resolve by such a deployment, but another was due to the strong coupling between VRF and ed25519, which I solved both by interfacing the |
a28dab3
to
f8d41a8
Compare
@@ -688,6 +687,8 @@ type Commit struct { | |||
BlockID BlockID `json:"block_id"` | |||
Signatures []CommitSig `json:"signatures"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you remove signature
of CommitSig
later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CommitSig
contains the address of "who signed" information, so I'll leave it in the block. I'm considering to set the Signature []byte
field in the CommitSig
to nil
or byte[0]
after aggregating the signatures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misunderstood a little bit; The CommitSig
is not only a meta-information of the block, but also used by each Voter
to send their signatures, so I'm considering to leave the Signature
field in CommitSig
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to define and use different types explicitly.
How about this
type Commit struct {
Height int64 `json:"height"`
Round int `json:"round"`
BlockID BlockID `json:"block_id"`
Signers []CommitSigner `json:"signers"`
AggregatedSignature []byte `json:"aggregated_signature"`
hash tmbytes.HexBytes
bitArray *bits.BitArray
}
type CommitSigner struct {
BlockIDFlag BlockIDFlag `json:"block_id_flag"`
ValidatorAddress Address `json:"validator_address"`
Timestamp time.Time `json:"timestamp"`
}
0f3c118
to
642e48c
Compare
6a504de
to
f72afd4
Compare
8eda5fc
to
2838143
Compare
2838143
to
6994d02
Compare
I'll write down the problems that took a long time to solve.
|
@@ -205,15 +204,20 @@ func (app *PersistentKVStoreApplication) execValidatorTx(tx []byte) types.Respon | |||
} | |||
|
|||
// update | |||
return app.updateValidator(types.Ed25519ValidatorUpdate(pubkey, power)) | |||
// TODO The type of public key to be restored should be kept its original type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any plan to change the type of public key later?
Because you point it as TODO
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the relevant part, but since there is no NewValidatorUpdate
in the develop branch, the PR of 107 needs to wait for the source code of 101 to be merged.
abci/tests/server/client.go
Outdated
power := tmrand.Int() | ||
vals[i] = types.Ed25519ValidatorUpdate(pubkey, int64(power)) | ||
vals[i] = types.NewValidatorUpdate("composite", pubkey, int64(power)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know ABCIPubKeyTypeComposite
is same string const type with "composite".
So, I think it's the better to use ABCIPubKeyTypeComposite
if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, I'll fix it.
@@ -5,10 +5,10 @@ import ( | |||
"fmt" | |||
"strings" | |||
|
|||
"github.com/tendermint/tendermint/cmd/contract_tests/unmarshaler" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why this import sorting is changed?
lint version is changed? or golang version is changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do different versions of goimports
give different results? I'm not sure why it was corrected, but this is the result of applying make format
(gofmt
) locally.
% go version
go version go1.14.4 darwin/amd64
if !cpk.Equals(pk) { | ||
t.Fatalf("The retrieved composite public key was not match: %+v != %+v", cpk, pk) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding more test for BLS12?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it.
types/priv_validator.go
Outdated
//signKey := bls.GenPrivKey() | ||
//vrfKey := ed25519.GenPrivKey() | ||
//return composite.NewPrivKeyComposite(signKey, vrfKey).PubKey(), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this lines don't need anymore, please remove this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
abci/example/kvstore/helpers.go
Outdated
) | ||
|
||
// RandVal creates one random validator, with a key derived | ||
// from the input value | ||
func RandVal(i int) types.ValidatorUpdate { | ||
pubkey := tmrand.Bytes(32) | ||
pk := composite.GenPrivKey().PubKey() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think choosing which key to use should be handled in one place. The same is true in codes for testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've defined another function that generates a private key for the example and tests.
type vrfEd25519 interface { | ||
Prove(privateKey ed25519.PrivKeyEd25519, message []byte) (Proof, error) | ||
Verify(publicKey ed25519.PubKeyEd25519, proof Proof, message []byte) (bool, error) | ||
Prove(privateKey []byte, publicKey []byte, message []byte) (Proof, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I ask the reason why you modified more specific parameter type(ed25519.PrivKeyEd25519
) to general type([]byte
)? I think it's better that vrfEd25519
interface methods use the type concerned with Ed25519.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fix intended to eliminate circular references in import
: since crypto/ed25519
must reference crypt/vrf
, a reference to crypto/ed25519
in crypt/vrf
will cause a circular reference. Indeed, passing the Ed25519 key type is better abstraction and natural, but we have to give preference to one over the other.
If golang supported type-class or generics, there would be a better way to write this, but for now, we use the generic notation as byte[]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I see.
70cead1
to
0b9f890
Compare
0b9f890
to
c6e66bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes: #95
Summary
PrivKey
andPubKey
interfaces to abstract VRF proving and verifying operation.Proof
andOutput
fromvrf
tocrypto
to avoid import circular references.Description
Introduces the BLS and Composite keys into the LINE Blockchain. This PR enables the BLS signature on the LINE Blockchain (VRF functionality remains with the Ed25519 key). It also enables the Composite key to differentiate between BSL and Ed25519 keys depending on their function.
Please note that BLS signature aggregation is a modification of the following.
For contributor use:
docs/
) and code commentsFiles changed
in the Github PR explorer