mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 06:54:41 +00:00
crypto: fix sr25519 from raw import (#4272)
* fix raw import sr25519 * add sr25519 to multisig codec * bump go-schnorrkel Co-authored-by: Marko <marbar3778@yahoo.com> Fixes sr25519 pubkey generation and signing when importing from raw bytes
This commit is contained in:
committed by
Anton Kaliaev
co-authored by
Marko
parent
7f655d8e9e
commit
279482ce99
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
"github.com/tendermint/tendermint/crypto/sr25519"
|
||||
)
|
||||
|
||||
// TODO: Figure out API for others to either add their own pubkey types, or
|
||||
@@ -21,6 +22,8 @@ func init() {
|
||||
PubKeyMultisigThresholdAminoRoute, nil)
|
||||
cdc.RegisterConcrete(ed25519.PubKeyEd25519{},
|
||||
ed25519.PubKeyAminoName, nil)
|
||||
cdc.RegisterConcrete(sr25519.PubKeySr25519{},
|
||||
sr25519.PubKeyAminoName, nil)
|
||||
cdc.RegisterConcrete(secp256k1.PubKeySecp256k1{},
|
||||
secp256k1.PubKeyAminoName, nil)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
"github.com/tendermint/tendermint/crypto/sr25519"
|
||||
)
|
||||
|
||||
// This tests multisig functionality, but it expects the first k signatures to be valid
|
||||
@@ -165,10 +166,13 @@ func generatePubKeysAndSignatures(n int, msg []byte) (pubkeys []crypto.PubKey, s
|
||||
signatures = make([][]byte, n)
|
||||
for i := 0; i < n; i++ {
|
||||
var privkey crypto.PrivKey
|
||||
if rand.Int63()%2 == 0 {
|
||||
switch rand.Int63() % 3 {
|
||||
case 0:
|
||||
privkey = ed25519.GenPrivKey()
|
||||
} else {
|
||||
case 1:
|
||||
privkey = secp256k1.GenPrivKey()
|
||||
case 2:
|
||||
privkey = sr25519.GenPrivKey()
|
||||
}
|
||||
pubkeys[i] = privkey.PubKey()
|
||||
signatures[i], _ = privkey.Sign(msg)
|
||||
|
||||
Reference in New Issue
Block a user