Skip to content

Commit

Permalink
pubkey
Browse files Browse the repository at this point in the history
  • Loading branch information
kimurayu45z committed Nov 21, 2024
1 parent 71e5caf commit 0ff3a79
Show file tree
Hide file tree
Showing 12 changed files with 428 additions and 430 deletions.
182 changes: 91 additions & 91 deletions api/gluon/customauth/operator/pubkey.pulsar.go

Large diffs are not rendered by default.

422 changes: 211 additions & 211 deletions api/gluon/customauth/pairing/pubkey.pulsar.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion proto/gluon/customauth/operator/pubkey.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package gluon.customauth.operator;

option go_package = "gluon/x/customauth/types/operator";

message PubKeyNotVerifiable {
message PubKey {
bytes user = 1;
}
4 changes: 2 additions & 2 deletions proto/gluon/customauth/pairing/pubkey.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import "google/protobuf/any.proto";

option go_package = "gluon/x/customauth/types/pairing";

message PubKeyNotVerifiable {
message PubKey {
bytes user = 1;
uint64 pairing_id = 2;
}

message PubKey {
message PubKeyInternal {
bytes user = 1;
google.protobuf.Any pairing_public_key = 2 [ (gogoproto.nullable) = false ];
google.protobuf.Any operator_public_key = 3 [ (gogoproto.nullable) = false ];
Expand Down
2 changes: 1 addition & 1 deletion x/customauth/ante/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ type FeegrantKeeper interface {
type CustomAuthKeeper interface {
GetParams(ctx context.Context) (params types.Params)
GetOperatorPubKey(ctx context.Context) (cryptotypes.PubKey, error)
GetPairingPubKey(goCtx context.Context, user sdk.AccAddress, pairingId uint64) (*pairing.PubKey, error)
GetPairingPubKey(goCtx context.Context, user sdk.AccAddress, pairingId uint64) (*pairing.PubKeyInternal, error)
}
4 changes: 2 additions & 2 deletions x/customauth/ante/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
// <gluon>
var pubKey cryptotypes.PubKey
switch pk := pubKeys[i].(type) {
case *operator.PubKeyNotVerifiable:
case *operator.PubKey:
if !isOperatorTx {
return ctx, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "operator pubkey can be used only for designated messages")
}
Expand All @@ -98,7 +98,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
return ctx, err
}

case *pairing.PubKeyNotVerifiable:
case *pairing.PubKey:
pubKey, err = svd.cak.GetPairingPubKey(ctx, acc.GetAddress(), pk.PairingId)
if err != nil {
return ctx, err
Expand Down
4 changes: 2 additions & 2 deletions x/customauth/keeper/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (k Keeper) getPairingPubKey(pairing types.Pairing) (cryptotypes.PubKey, err
return pubKey, nil
}

func (k Keeper) GetPairingPubKey(goCtx context.Context, user sdk.AccAddress, pairingId uint64) (*pairing.PubKey, error) {
func (k Keeper) GetPairingPubKey(goCtx context.Context, user sdk.AccAddress, pairingId uint64) (*pairing.PubKeyInternal, error) {
pairingVal, found := k.GetPairing(goCtx, user.String(), pairingId)
if !found {
return nil, errorsmod.Wrapf(types.ErrPairingNotFound, "address: %s, pairing_id: %d", user.String(), pairingId)
Expand All @@ -147,7 +147,7 @@ func (k Keeper) GetPairingPubKey(goCtx context.Context, user sdk.AccAddress, pai
return nil, errorsmod.Wrapf(types.ErrPairingDelayPeriod, "address: %s, pairing_id: %d", user.String(), pairingId)
}

pubKey := pairing.PubKey{
pubKey := pairing.PubKeyInternal{
User: user,
PairingPublicKey: pairingVal.PublicKey,
OperatorPublicKey: params.OperatorPublicKey,
Expand Down
4 changes: 2 additions & 2 deletions x/customauth/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
registry.RegisterImplementations((*cryptotypes.PubKey)(nil),
&operator.PubKeyNotVerifiable{},
&pairing.PubKeyNotVerifiable{},
&operator.PubKey{},
&pairing.PubKey{},
)

registry.RegisterImplementations((*sdk.Msg)(nil),
Expand Down
14 changes: 7 additions & 7 deletions x/customauth/types/operator/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)

var _ cryptotypes.PubKey = &PubKeyNotVerifiable{}
var _ cryptotypes.PubKey = &PubKey{}

func (pk PubKeyNotVerifiable) Address() cometbytes.HexBytes {
func (pk PubKey) Address() cometbytes.HexBytes {
return pk.User
}

func (pk PubKeyNotVerifiable) Bytes() []byte {
func (pk PubKey) Bytes() []byte {
return nil
}

func (pk PubKeyNotVerifiable) VerifySignature(msg []byte, sig []byte) bool {
func (pk PubKey) VerifySignature(msg []byte, sig []byte) bool {
return false
}

func (pk PubKeyNotVerifiable) Equals(other cryptotypes.PubKey) bool {
func (pk PubKey) Equals(other cryptotypes.PubKey) bool {
switch other := other.(type) {
case *PubKeyNotVerifiable:
case *PubKey:
return bytes.Equal(pk.User, other.User)
default:
return false
}

}

func (pk PubKeyNotVerifiable) Type() string {
func (pk PubKey) Type() string {
return "operator"
}
63 changes: 31 additions & 32 deletions x/customauth/types/operator/pubkey.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions x/customauth/types/pairing/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,63 @@ import (
txsigning "github.com/cosmos/cosmos-sdk/types/tx/signing"
)

var _ cryptotypes.PubKey = &PubKeyNotVerifiable{}
var _ cryptotypes.PubKey = &PubKey{}

func (pk PubKeyNotVerifiable) Address() cometbytes.HexBytes {
func (pk PubKey) Address() cometbytes.HexBytes {
return pk.User
}

func (pk PubKeyNotVerifiable) Bytes() []byte {
func (pk PubKey) Bytes() []byte {
return nil
}

func (pk PubKeyNotVerifiable) VerifySignature(msg []byte, sig []byte) bool {
func (pk PubKey) VerifySignature(msg []byte, sig []byte) bool {
return false
}

func (pk PubKeyNotVerifiable) Equals(other cryptotypes.PubKey) bool {
func (pk PubKey) Equals(other cryptotypes.PubKey) bool {
switch other := other.(type) {
case *PubKeyNotVerifiable:
case *PubKey:
return bytes.Equal(pk.User, other.User) && pk.PairingId == other.PairingId
default:
return false
}
}

func (pk PubKeyNotVerifiable) Type() string {
func (pk PubKey) Type() string {
return "pairing"
}

var _ multisig.PubKey = &PubKey{}
var _ multisig.PubKey = &PubKeyInternal{}

func (pk PubKey) Address() cometbytes.HexBytes {
func (pk PubKeyInternal) Address() cometbytes.HexBytes {
return pk.User
}

func (pk PubKey) Bytes() []byte {
func (pk PubKeyInternal) Bytes() []byte {
return nil
}

func (pk PubKey) VerifySignature(msg []byte, sig []byte) bool {
func (pk PubKeyInternal) VerifySignature(msg []byte, sig []byte) bool {
return false
}

func (pk PubKey) Equals(other cryptotypes.PubKey) bool {
func (pk PubKeyInternal) Equals(other cryptotypes.PubKey) bool {
return false
}

func (pk PubKey) Type() string {
func (pk PubKeyInternal) Type() string {
return "pairing"
}

func (pk PubKey) VerifyMultisignature(getSignBytes multisig.GetSignBytesFunc, sig *txsigning.MultiSignatureData) error {
func (pk PubKeyInternal) VerifyMultisignature(getSignBytes multisig.GetSignBytesFunc, sig *txsigning.MultiSignatureData) error {
return nil
}

func (pk PubKey) GetPubKeys() []cryptotypes.PubKey {
func (pk PubKeyInternal) GetPubKeys() []cryptotypes.PubKey {
return nil
}

func (pk PubKey) GetThreshold() uint {
func (pk PubKeyInternal) GetThreshold() uint {
return 2
}
Loading

0 comments on commit 0ff3a79

Please sign in to comment.