Skip to content

Commit

Permalink
fix: more bn254 cases
Browse files Browse the repository at this point in the history
  • Loading branch information
PoisonPhang committed Oct 9, 2024
1 parent 06a0b43 commit 90fe926
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions crypto/codec/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

cryptokeys "github.com/cosmos/cosmos-sdk/crypto/keys"
bls12_381 "github.com/cosmos/cosmos-sdk/crypto/keys/bls12_381"
bn254 "github.com/cosmos/cosmos-sdk/crypto/keys/bn254"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand All @@ -25,6 +26,10 @@ func PubKeyToProto(pk cryptokeys.JSONPubkey) (cryptotypes.PubKey, error) {
return &bls12_381.PubKey{
Key: pk.Value,
}, nil
case bn254.PubKeyName:
return &bn254.PubKey{
Key: pk.Value,
}, nil
default:
return nil, errors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v to proto public key", pk)
}
Expand All @@ -47,6 +52,11 @@ func PubKeyFromProto(pk cryptotypes.PubKey) (cryptokeys.JSONPubkey, error) {
KeyType: bls12_381.PubKeyName,
Value: pk.Bytes(),
}, nil
case *bn254.PubKey:
return cryptokeys.JSONPubkey{
KeyType: bn254.PrivKeyName,
Value: pk.Bytes(),
}, nil
default:
return cryptokeys.JSONPubkey{}, errors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v from proto public key", pk)
}
Expand Down
6 changes: 6 additions & 0 deletions crypto/keys/jsonkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keys

import (
"github.com/cosmos/cosmos-sdk/crypto/keys/bls12_381"
"github.com/cosmos/cosmos-sdk/crypto/keys/bn254"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/types"
Expand Down Expand Up @@ -31,6 +32,11 @@ func (pk JSONPubkey) Address() types.Address {
Key: pk.Value,
}
return bls12_381.Address()
case bn254.PubKeyName:
bn254 := bn254.PubKey{
Key: pk.Value,
}
return bn254.Address()
default:
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ go 1.23.1
module github.com/cosmos/cosmos-sdk

require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
cosmossdk.io/api v0.8.0 // main
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // main
cosmossdk.io/core v1.0.0-alpha.4
Expand Down

0 comments on commit 90fe926

Please sign in to comment.