feat(crypto): add blst (#20296)
Co-authored-by: itsdevbear <itsdevbear@berachain.com> Co-authored-by: Akhil Kumar P <36399231+akhilkumarpilli@users.noreply.github.com>
This commit is contained in:
co-authored by
itsdevbear
Akhil Kumar P
parent
78327f40c5
commit
05ff7a7cb7
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/cometbft/cometbft/crypto/sr25519"
|
||||
|
||||
"cosmossdk.io/core/legacy"
|
||||
|
||||
bls12_381 "github.com/cosmos/cosmos-sdk/crypto/keys/bls12_381"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
@@ -21,6 +21,7 @@ func RegisterCrypto(cdc legacy.Amino) {
|
||||
ed25519.PubKeyName)
|
||||
cdc.RegisterConcrete(&secp256k1.PubKey{},
|
||||
secp256k1.PubKeyName)
|
||||
cdc.RegisterConcrete(&bls12_381.PubKey{}, bls12_381.PubKeyName)
|
||||
cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{},
|
||||
kmultisig.PubKeyAminoRoute)
|
||||
|
||||
@@ -31,4 +32,5 @@ func RegisterCrypto(cdc legacy.Amino) {
|
||||
ed25519.PrivKeyName)
|
||||
cdc.RegisterConcrete(&secp256k1.PrivKey{},
|
||||
secp256k1.PrivKeyName)
|
||||
cdc.RegisterConcrete(&bls12_381.PrivKey{}, bls12_381.PrivKeyName)
|
||||
}
|
||||
|
||||
+11
-1
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/cometbft/cometbft/crypto/encoding"
|
||||
|
||||
"cosmossdk.io/errors"
|
||||
|
||||
bls12_381 "github.com/cosmos/cosmos-sdk/crypto/keys/bls12_381"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
@@ -24,6 +24,10 @@ func FromCmtProtoPublicKey(protoPk cmtprotocrypto.PublicKey) (cryptotypes.PubKey
|
||||
return &secp256k1.PubKey{
|
||||
Key: protoPk.Secp256K1,
|
||||
}, nil
|
||||
case *cmtprotocrypto.PublicKey_Bls12381:
|
||||
return &bls12_381.PubKey{
|
||||
Key: protoPk.Bls12381,
|
||||
}, nil
|
||||
default:
|
||||
return nil, errors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v from Tendermint public key", protoPk)
|
||||
}
|
||||
@@ -44,6 +48,12 @@ func ToCmtProtoPublicKey(pk cryptotypes.PubKey) (cmtprotocrypto.PublicKey, error
|
||||
Secp256K1: pk.Key,
|
||||
},
|
||||
}, nil
|
||||
case *bls12_381.PubKey:
|
||||
return cmtprotocrypto.PublicKey{
|
||||
Sum: &cmtprotocrypto.PublicKey_Bls12381{
|
||||
Bls12381: pk.Key,
|
||||
},
|
||||
}, nil
|
||||
default:
|
||||
return cmtprotocrypto.PublicKey{}, errors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v to Tendermint public key", pk)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package codec
|
||||
import (
|
||||
"cosmossdk.io/core/registry"
|
||||
|
||||
bls12_381 "github.com/cosmos/cosmos-sdk/crypto/keys/bls12_381"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
@@ -16,11 +17,13 @@ func RegisterInterfaces(registry registry.InterfaceRegistrar) {
|
||||
registry.RegisterInterface("cosmos.crypto.PubKey", pk)
|
||||
registry.RegisterImplementations(pk, &ed25519.PubKey{})
|
||||
registry.RegisterImplementations(pk, &secp256k1.PubKey{})
|
||||
registry.RegisterImplementations(pk, &bls12_381.PubKey{})
|
||||
registry.RegisterImplementations(pk, &multisig.LegacyAminoPubKey{})
|
||||
|
||||
var priv *cryptotypes.PrivKey
|
||||
registry.RegisterInterface("cosmos.crypto.PrivKey", priv)
|
||||
registry.RegisterImplementations(priv, &secp256k1.PrivKey{})
|
||||
registry.RegisterImplementations(priv, &ed25519.PrivKey{})
|
||||
registry.RegisterImplementations(priv, &bls12_381.PrivKey{})
|
||||
secp256r1.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user