Repository navigation
crypto: add BLS12381 validator key type - #2
Conversation
alexanderbez
left a comment
There was a problem hiding this comment.
Changes look great so far. I can't speak to the CGO or actual BLS code, but so far it seems to be on the right path 👍
| func TxPreCheck(state State) mempl.PreCheckFunc { | ||
| maxDataBytes := types.MaxDataBytesUnknownEvidence( | ||
| state.ConsensusParams.Block.MaxBytes, | ||
| crypto.BLS12381, |
There was a problem hiding this comment.
Why is this change necessary?
There was a problem hiding this comment.
Its because signature sizes are different in BLS and ED keys, which will change the max data bytes.
BLS public keys are 48 bytes and sigs are 96 bytes. Ed public keys are 32 bytes and sigs are 64 bytes. So a 16 byte difference for a public key and a 32 byte difference for the signature.
maxEvidenceBytes := int64(maxNumEvidence) * MaxEvidenceBytesForKeyType(keyType) maxDataBytes := maxBytes - MaxOverheadForBlock - MaxHeaderBytes - int64(valsCount)*MaxVoteBytesForKeyType(keyType) - maxEvidenceBytes
The max evidence bytes should then vary by the difference in public key size and signature size, here 48.
The max vote size should vary by the signature size, here 32.
I wrote this a while ago so am not 100% sure of my logic. I guess I should have commented more.
There was a problem hiding this comment.
Makes sense! Yes, I'd add a small godoc on this explaining how/why.
| func TestTxFilter(t *testing.T) { | ||
| genDoc := randomGenesisDoc() | ||
| genDoc.ConsensusParams.Block.MaxBytes = 3000 | ||
| genDoc.ConsensusParams.Block.MaxBytes = 3080 |
There was a problem hiding this comment.
Reasoning for this change?
There was a problem hiding this comment.
There is a difference of 48 in the max evidence size and 32 in the max vote size so 80 total for 1 evidence and 1 validator.
| // | ||
| // XXX: Panics on negative result. | ||
| func MaxDataBytes(maxBytes int64, valsCount, evidenceCount int) int64 { | ||
| func MaxDataBytes(maxBytes int64, keyType crypto.KeyType, valsCount, evidenceCount int) int64 { |
There was a problem hiding this comment.
Why do we need a key type provided in these?
There was a problem hiding this comment.
Same reason as stated above.
alexanderbez
left a comment
There was a problem hiding this comment.
Going to approve this 👍
Also, any chance we can get CI tests to pass? I took a very brief look and it seems some of the C++/CGO stuff is missing?
revert unrelated changes
|
@QuantumExplorer hey! Why do you update markdown documents formatting in this PR? |
shumkov
left a comment
There was a problem hiding this comment.
LGTM! Agreed to disabled some actions due to issue with cgo
Improvement/core signer2
Description
This pull request adds bls12381 keys to tendermint. The Dash ecosystem heavily relies on BLS keys in the masternode network for threshold signing and distributed key generation. Out of scope of this pull request is all key or signature aggregation and threshold signing.