mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
crypto: Remove unnecessary prefixes from amino route variable names (#2205)
* crypto: Remove unnecessary ed25519 and secp256k1 prefixes from amino routes. * (squash this) add changelog * (squash this) multisig amino fixes * (squash this) fix build error
This commit is contained in:
parent
e10666859f
commit
728d2ed266
@ -10,6 +10,7 @@ BREAKING CHANGES:
|
|||||||
- [abci] Added address of the original proposer of the block to Header.
|
- [abci] Added address of the original proposer of the block to Header.
|
||||||
- [abci] Change ABCI Header to match Tendermint exactly
|
- [abci] Change ABCI Header to match Tendermint exactly
|
||||||
- [libs] Remove cmn.Fmt, in favor of fmt.Sprintf
|
- [libs] Remove cmn.Fmt, in favor of fmt.Sprintf
|
||||||
|
- [crypto] Rename AminoRoute variables to no longer be prefixed by signature type.
|
||||||
- [config] Replace MaxNumPeers with MaxNumInboundPeers and MaxNumOutboundPeers
|
- [config] Replace MaxNumPeers with MaxNumInboundPeers and MaxNumOutboundPeers
|
||||||
|
|
||||||
FEATURES:
|
FEATURES:
|
||||||
|
@ -23,7 +23,7 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) {
|
|||||||
Hash: cmn.RandBytes(20),
|
Hash: cmn.RandBytes(20),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
sig := make([]byte, ed25519.SignatureEd25519Size)
|
sig := make([]byte, ed25519.SignatureSize)
|
||||||
for i := 0; i < nval; i++ {
|
for i := 0; i < nval; i++ {
|
||||||
precommits[i] = &types.Vote{
|
precommits[i] = &types.Vote{
|
||||||
ValidatorAddress: types.Address(cmn.RandBytes(20)),
|
ValidatorAddress: types.Address(cmn.RandBytes(20)),
|
||||||
|
@ -18,11 +18,11 @@ import (
|
|||||||
var _ crypto.PrivKey = PrivKeyEd25519{}
|
var _ crypto.PrivKey = PrivKeyEd25519{}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Ed25519PrivKeyAminoRoute = "tendermint/PrivKeyEd25519"
|
PrivKeyAminoRoute = "tendermint/PrivKeyEd25519"
|
||||||
Ed25519PubKeyAminoRoute = "tendermint/PubKeyEd25519"
|
PubKeyAminoRoute = "tendermint/PubKeyEd25519"
|
||||||
// Size of an Edwards25519 signature. Namely the size of a compressed
|
// Size of an Edwards25519 signature. Namely the size of a compressed
|
||||||
// Edwards25519 point, and a field element. Both of which are 32 bytes.
|
// Edwards25519 point, and a field element. Both of which are 32 bytes.
|
||||||
SignatureEd25519Size = 64
|
SignatureSize = 64
|
||||||
)
|
)
|
||||||
|
|
||||||
var cdc = amino.NewCodec()
|
var cdc = amino.NewCodec()
|
||||||
@ -30,11 +30,11 @@ var cdc = amino.NewCodec()
|
|||||||
func init() {
|
func init() {
|
||||||
cdc.RegisterInterface((*crypto.PubKey)(nil), nil)
|
cdc.RegisterInterface((*crypto.PubKey)(nil), nil)
|
||||||
cdc.RegisterConcrete(PubKeyEd25519{},
|
cdc.RegisterConcrete(PubKeyEd25519{},
|
||||||
Ed25519PubKeyAminoRoute, nil)
|
PubKeyAminoRoute, nil)
|
||||||
|
|
||||||
cdc.RegisterInterface((*crypto.PrivKey)(nil), nil)
|
cdc.RegisterInterface((*crypto.PrivKey)(nil), nil)
|
||||||
cdc.RegisterConcrete(PrivKeyEd25519{},
|
cdc.RegisterConcrete(PrivKeyEd25519{},
|
||||||
Ed25519PrivKeyAminoRoute, nil)
|
PrivKeyAminoRoute, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrivKeyEd25519 implements crypto.PrivKey.
|
// PrivKeyEd25519 implements crypto.PrivKey.
|
||||||
@ -158,10 +158,10 @@ func (pubKey PubKeyEd25519) Bytes() []byte {
|
|||||||
|
|
||||||
func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ []byte) bool {
|
func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ []byte) bool {
|
||||||
// make sure we use the same algorithm to sign
|
// make sure we use the same algorithm to sign
|
||||||
if len(sig_) != SignatureEd25519Size {
|
if len(sig_) != SignatureSize {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
sig := new([SignatureEd25519Size]byte)
|
sig := new([SignatureSize]byte)
|
||||||
copy(sig[:], sig_)
|
copy(sig[:], sig_)
|
||||||
pubKeyBytes := [PubKeyEd25519Size]byte(pubKey)
|
pubKeyBytes := [PubKeyEd25519Size]byte(pubKey)
|
||||||
return ed25519.Verify(&pubKeyBytes, msg, sig)
|
return ed25519.Verify(&pubKeyBytes, msg, sig)
|
||||||
|
@ -30,7 +30,8 @@ func randCompactBitArray(bits int) (*CompactBitArray, []byte) {
|
|||||||
func TestNewBitArrayNeverCrashesOnNegatives(t *testing.T) {
|
func TestNewBitArrayNeverCrashesOnNegatives(t *testing.T) {
|
||||||
bitList := []int{-127, -128, -1 << 31}
|
bitList := []int{-127, -128, -1 << 31}
|
||||||
for _, bits := range bitList {
|
for _, bits := range bitList {
|
||||||
_ = NewCompactBitArray(bits)
|
bA := NewCompactBitArray(bits)
|
||||||
|
require.Nil(t, bA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
// TODO: Figure out API for others to either add their own pubkey types, or
|
// TODO: Figure out API for others to either add their own pubkey types, or
|
||||||
// to make verify / marshal accept a cdc.
|
// to make verify / marshal accept a cdc.
|
||||||
const (
|
const (
|
||||||
ThresholdPubkeyAminoRoute = "tendermint/PubkeyThresholdMultisig"
|
ThresholdPubkeyAminoRoute = "tendermint/PubkeyMultisigThreshold"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cdc = amino.NewCodec()
|
var cdc = amino.NewCodec()
|
||||||
@ -20,7 +20,7 @@ func init() {
|
|||||||
cdc.RegisterConcrete(ThresholdMultiSignaturePubKey{},
|
cdc.RegisterConcrete(ThresholdMultiSignaturePubKey{},
|
||||||
ThresholdPubkeyAminoRoute, nil)
|
ThresholdPubkeyAminoRoute, nil)
|
||||||
cdc.RegisterConcrete(ed25519.PubKeyEd25519{},
|
cdc.RegisterConcrete(ed25519.PubKeyEd25519{},
|
||||||
ed25519.Ed25519PubKeyAminoRoute, nil)
|
ed25519.PubKeyAminoRoute, nil)
|
||||||
cdc.RegisterConcrete(secp256k1.PubKeySecp256k1{},
|
cdc.RegisterConcrete(secp256k1.PubKeySecp256k1{},
|
||||||
secp256k1.Secp256k1PubKeyAminoRoute, nil)
|
secp256k1.PubKeyAminoRoute, nil)
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
const (
|
const (
|
||||||
Secp256k1PrivKeyAminoRoute = "tendermint/PrivKeySecp256k1"
|
PrivKeyAminoRoute = "tendermint/PrivKeySecp256k1"
|
||||||
Secp256k1PubKeyAminoRoute = "tendermint/PubKeySecp256k1"
|
PubKeyAminoRoute = "tendermint/PubKeySecp256k1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cdc = amino.NewCodec()
|
var cdc = amino.NewCodec()
|
||||||
@ -24,11 +24,11 @@ var cdc = amino.NewCodec()
|
|||||||
func init() {
|
func init() {
|
||||||
cdc.RegisterInterface((*crypto.PubKey)(nil), nil)
|
cdc.RegisterInterface((*crypto.PubKey)(nil), nil)
|
||||||
cdc.RegisterConcrete(PubKeySecp256k1{},
|
cdc.RegisterConcrete(PubKeySecp256k1{},
|
||||||
Secp256k1PubKeyAminoRoute, nil)
|
PubKeyAminoRoute, nil)
|
||||||
|
|
||||||
cdc.RegisterInterface((*crypto.PrivKey)(nil), nil)
|
cdc.RegisterInterface((*crypto.PrivKey)(nil), nil)
|
||||||
cdc.RegisterConcrete(PrivKeySecp256k1{},
|
cdc.RegisterConcrete(PrivKeySecp256k1{},
|
||||||
Secp256k1PrivKeyAminoRoute, nil)
|
PrivKeyAminoRoute, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user