From d996c1e7d8f0ba522f1a28437db61c42af86c39d Mon Sep 17 00:00:00 2001 From: mj Date: Mon, 4 Nov 2024 10:19:34 -0500 Subject: [PATCH 1/8] new types --- go.mod | 14 +- go.sum | 12 + proto/confidentialtransfers/tx.proto | 29 +- proto/confidentialtransfers/zk.proto | 11 +- x/confidentialtransfers/types/codec.go | 8 + .../types/initialize_account.go | 18 + x/confidentialtransfers/types/msgs.go | 77 +- x/confidentialtransfers/types/msgs_test.go | 140 ++- x/confidentialtransfers/types/transfer.go | 4 +- x/confidentialtransfers/types/tx.pb.go | 1034 +++++++++++++++-- x/confidentialtransfers/types/zk.go | 81 +- x/confidentialtransfers/types/zk.pb.go | 562 +++++++-- x/confidentialtransfers/types/zk_test.go | 122 +- x/evm/types/params.pb.go | 334 ++++++ 14 files changed, 2228 insertions(+), 218 deletions(-) create mode 100644 x/confidentialtransfers/types/initialize_account.go diff --git a/go.mod b/go.mod index fc3abaf7a8..51d8da5726 100644 --- a/go.mod +++ b/go.mod @@ -45,9 +45,9 @@ require ( golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa golang.org/x/sync v0.8.0 golang.org/x/time v0.3.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 - google.golang.org/grpc v1.64.1 - google.golang.org/protobuf v1.34.2 + google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 + google.golang.org/grpc v1.67.1 + google.golang.org/protobuf v1.35.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -176,7 +176,7 @@ require ( github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect @@ -322,13 +322,13 @@ require ( golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect golang.org/x/mod v0.18.0 // indirect - golang.org/x/net v0.26.0 // indirect + golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.25.0 // indirect golang.org/x/term v0.24.0 // indirect - golang.org/x/text v0.18.0 // indirect + golang.org/x/text v0.19.0 // indirect golang.org/x/tools v0.22.0 // indirect google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect honnef.co/go/tools v0.3.1 // indirect diff --git a/go.sum b/go.sum index b4e4255c30..7896069f84 100644 --- a/go.sum +++ b/go.sum @@ -773,6 +773,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= @@ -1807,6 +1809,8 @@ golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20170207211851-4464e7848382/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -2009,6 +2013,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2274,8 +2280,12 @@ google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac h1:ZL/Teoy/ZGnzyrq google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw= +google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc= google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2295,6 +2305,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/proto/confidentialtransfers/tx.proto b/proto/confidentialtransfers/tx.proto index 21b8ecb04e..b9cf8dc88b 100644 --- a/proto/confidentialtransfers/tx.proto +++ b/proto/confidentialtransfers/tx.proto @@ -28,11 +28,11 @@ message MsgTransfer { Ciphertext to_amount_hi = 7 [(gogoproto.moretags) = "yaml:\"to_amount_hi\""]; Ciphertext remaining_balance = 8 [(gogoproto.moretags) = "yaml:\"decryptable_balance\""]; string decryptable_balance = 9 [(gogoproto.moretags) = "yaml:\"decryptable_balance\""]; - TransferProofs proofs = 10 [(gogoproto.moretags) = "yaml:\"proofs\""]; + TransferMsgProofs proofs = 10 [(gogoproto.moretags) = "yaml:\"proofs\""]; repeated Auditor auditors = 11 [(gogoproto.moretags) = "yaml:\"auditors\""]; } -// MsgSendResponse defines the Msg/Send response type. +// MsgTransferResponse defines the Msg/Send response type. message MsgTransferResponse {} message Auditor { @@ -44,3 +44,28 @@ message Auditor { CiphertextCiphertextEqualityProof transfer_amount_lo_equality_proof = 6 [(gogoproto.moretags) = "yaml:\"transfer_amount_lo_equality_proof\""]; CiphertextCiphertextEqualityProof transfer_amount_hi_equality_proof = 7 [(gogoproto.moretags) = "yaml:\"transfer_amount_hi_equality_proof\""]; } + +// MsgInitializeAccount represents a message to create a new confidential transfer account. +message MsgInitializeAccount { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string denom = 2 [(gogoproto.moretags) = "yaml:\"denom\""]; + bytes public_key = 3 [(gogoproto.moretags) = "yaml:\"public_key\""]; + string decryptable_balance = 4 [(gogoproto.moretags) = "yaml:\"decryptable_balance\""]; + InitializeAccountMsgProofs proofs = 5 [(gogoproto.moretags) = "yaml:\"proofs\""]; +} + +// MsgInitializeAccountResponse defines the Msg/Send response type. +message MsgInitializeAccountResponse {} + +// MsgDeposit represents a message for depositing tokens into a confidential account +message MsgDeposit { + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string denom = 2 [(gogoproto.moretags) = "yaml:\"denom\""]; + uint64 amount = 3 [(gogoproto.moretags) = "yaml:\"amount\""]; +} + +// MsgDepositResponse defines the Msg/Send response type. +message MsgDepositResponse {} \ No newline at end of file diff --git a/proto/confidentialtransfers/zk.proto b/proto/confidentialtransfers/zk.proto index 195eb00931..be02d57535 100644 --- a/proto/confidentialtransfers/zk.proto +++ b/proto/confidentialtransfers/zk.proto @@ -4,7 +4,7 @@ package seiprotocol.seichain.confidentialtransfers; option go_package = "github.com/sei-protocol/sei-chain/x/confidentialtransfers/types"; -message TransferProofs { +message TransferMsgProofs { CiphertextValidityProof remaining_balance_commitment_validity_proof = 1; CiphertextValidityProof sender_transfer_amount_lo_validity_proof = 2; CiphertextValidityProof sender_transfer_amount_hi_validity_proof = 3; @@ -16,6 +16,15 @@ message TransferProofs { CiphertextCiphertextEqualityProof transfer_amount_hi_equality_proof = 9; } +message InitializeAccountMsgProofs { + PubkeyValidityProof pubkey_validity_proof = 1; +} + +message PubkeyValidityProof { + bytes y = 1; + bytes z = 2; +} + message CiphertextValidityProof { // First commitment bytes commitment_1 = 1; diff --git a/x/confidentialtransfers/types/codec.go b/x/confidentialtransfers/types/codec.go index ff55fd9a73..a88d5d071f 100644 --- a/x/confidentialtransfers/types/codec.go +++ b/x/confidentialtransfers/types/codec.go @@ -9,12 +9,20 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgTransfer{}, "confidentialtransfers/MsgTransfer", nil) + cdc.RegisterConcrete(&MsgInitializeAccount{}, "confidentialtransfers/MsgInitializeAccount", nil) + cdc.RegisterConcrete(&MsgDeposit{}, "confidentialtransfers/MsgDeposit", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgTransfer{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgInitializeAccount{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgDeposit{}, + ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/confidentialtransfers/types/initialize_account.go b/x/confidentialtransfers/types/initialize_account.go new file mode 100644 index 0000000000..01d68bb329 --- /dev/null +++ b/x/confidentialtransfers/types/initialize_account.go @@ -0,0 +1,18 @@ +package types + +import ( + "github.com/coinbase/kryptology/pkg/core/curves" + "github.com/sei-protocol/sei-cryptography/pkg/zkproofs" +) + +type InitializeAccount struct { + FromAddress string `json:"from_address"` + Denom string `json:"denom"` + Pubkey *curves.Point `json:"pubkey"` + DecryptableBalance string `json:"decryptable_balance"` + Proofs *InitializeAccountProofs `json:"proofs"` +} + +type InitializeAccountProofs struct { + PubkeyValidityProof *zkproofs.PubKeyValidityProof `json:"pubkey_validity_proof"` +} diff --git a/x/confidentialtransfers/types/msgs.go b/x/confidentialtransfers/types/msgs.go index 182998f9fa..f522ed6a45 100644 --- a/x/confidentialtransfers/types/msgs.go +++ b/x/confidentialtransfers/types/msgs.go @@ -1,16 +1,19 @@ package types import ( + "github.com/coinbase/kryptology/pkg/core/curves" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // confidential transfers message types const ( - TypeMsgTransfer = "transfer" + TypeMsgTransfer = "transfer" + TypeMsgInitializeAccount = "initialize_account" ) var _ sdk.Msg = &MsgTransfer{} +var _ sdk.Msg = &MsgInitializeAccount{} // Route Implements Msg. func (m *MsgTransfer) Route() string { return RouterKey } @@ -134,3 +137,75 @@ func (m *MsgTransfer) FromProto() (*Transfer, error) { Auditors: auditors, }, nil } + +// Route Implements Msg. +func (m *MsgInitializeAccount) Route() string { return RouterKey } + +// Type Implements Msg. +func (m *MsgInitializeAccount) Type() string { return TypeMsgInitializeAccount } + +func (m *MsgInitializeAccount) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.FromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + err = sdk.ValidateDenom(m.Denom) + if err != nil { + return err + } + + if m.PublicKey == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "PublicKey is required") + } + + if m.DecryptableBalance == "" { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "DecryptableBalance is required") + } + + if m.Proofs == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Proofs is required") + } + + err = m.Proofs.Validate() + if err != nil { + return err + } + + return nil +} + +func (m *MsgInitializeAccount) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +func (m *MsgInitializeAccount) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.FromAddress) + return []sdk.AccAddress{sender} +} + +func (m *MsgInitializeAccount) FromProto() (*InitializeAccount, error) { + err := m.ValidateBasic() + if err != nil { + return nil, err + } + ed25519Curve := curves.ED25519() + + pubkey, err := ed25519Curve.Point.FromAffineCompressed(m.PublicKey) + if err != nil { + return nil, err + } + + proofs, err := m.Proofs.FromProto() + if err != nil { + return nil, err + } + + return &InitializeAccount{ + FromAddress: m.FromAddress, + Denom: m.Denom, + Pubkey: &pubkey, + DecryptableBalance: m.DecryptableBalance, + Proofs: proofs, + }, nil +} diff --git a/x/confidentialtransfers/types/msgs_test.go b/x/confidentialtransfers/types/msgs_test.go index 46d9128e99..291d84e1cb 100644 --- a/x/confidentialtransfers/types/msgs_test.go +++ b/x/confidentialtransfers/types/msgs_test.go @@ -1,6 +1,7 @@ package types import ( + crand "crypto/rand" "github.com/coinbase/kryptology/pkg/core/curves" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -40,9 +41,8 @@ func TestMsgTransfer_FromProto(t *testing.T) { sourceCiphertextAmountHiValidityProof, _ := zkproofs.NewCiphertextValidityProof(&sourceCiphertextAmountHiR, sourceKeypair.PublicKey, sourceCiphertextAmountHi, amountHi) - ciphertext := &Ciphertext{} - fromAmountLo := ciphertext.ToProto(sourceCiphertextAmountLo) - fromAmountHi := ciphertext.ToProto(sourceCiphertextAmountHi) + fromAmountLo := NewCiphertextProto(sourceCiphertextAmountLo) + fromAmountHi := NewCiphertextProto(sourceCiphertextAmountHi) destinationCipherAmountLo, destinationCipherAmountLoR, _ := eg.Encrypt(destinationKeypair.PublicKey, amountLo) destinationCipherAmountLoValidityProof, _ := @@ -51,11 +51,11 @@ func TestMsgTransfer_FromProto(t *testing.T) { destinationCipherAmountHiValidityProof, _ := zkproofs.NewCiphertextValidityProof(&destinationCipherAmountHiR, destinationKeypair.PublicKey, destinationCipherAmountHi, amountHi) - destinationAmountLo := ciphertext.ToProto(destinationCipherAmountLo) - destinationAmountHi := ciphertext.ToProto(destinationCipherAmountHi) + destinationAmountLo := NewCiphertextProto(destinationCipherAmountLo) + destinationAmountHi := NewCiphertextProto(destinationCipherAmountHi) remainingBalanceCiphertext, remainingBalanceRandomness, _ := eg.Encrypt(sourceKeypair.PublicKey, remainingBalance) - remainingBalanceProto := ciphertext.ToProto(remainingBalanceCiphertext) + remainingBalanceProto := NewCiphertextProto(remainingBalanceCiphertext) remainingBalanceCommitmentValidityProof, _ := zkproofs.NewCiphertextValidityProof(&remainingBalanceRandomness, sourceKeypair.PublicKey, remainingBalanceCiphertext, remainingBalance) @@ -88,7 +88,7 @@ func TestMsgTransfer_FromProto(t *testing.T) { &destinationCipherAmountHiR, &scalarAmountHi) - proofs := &Proofs{ + proofs := &TransferProofs{ RemainingBalanceCommitmentValidityProof: remainingBalanceCommitmentValidityProof, SenderTransferAmountLoValidityProof: sourceCiphertextAmountLoValidityProof, SenderTransferAmountHiValidityProof: sourceCiphertextAmountHiValidityProof, @@ -100,7 +100,7 @@ func TestMsgTransfer_FromProto(t *testing.T) { TransferAmountHiEqualityProof: transferAmountHiEqualityProof, } - transferProofs := &TransferProofs{} + transferProofs := &TransferMsgProofs{} proofsProto := transferProofs.ToProto(proofs) address1 := sdk.AccAddress("address1") address2 := sdk.AccAddress("address2") @@ -397,3 +397,127 @@ func TestMsgTransfer_ValidateBasic(t *testing.T) { }) } } + +func TestMsgInitializeAccount_FromProto(t *testing.T) { + testDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + sourcePrivateKey, _ := encryption.GenerateKey() + eg := elgamal.NewTwistedElgamal() + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, testDenom) + aesPK, err := encryption.GetAESKey(*sourcePrivateKey, testDenom) + require.NoError(t, err) + + decryptableBalance, err := encryption.EncryptAESGCM(0, aesPK) + + // Generate the proof + pubkeyValidityProof, _ := zkproofs.NewPubKeyValidityProof( + sourceKeypair.PublicKey, + sourceKeypair.PrivateKey) + + proofs := &InitializeAccountProofs{ + pubkeyValidityProof, + } + address1 := sdk.AccAddress("address1") + + proofsProto := NewInitializeAccountMsgProofs(proofs) + m := &MsgInitializeAccount{ + FromAddress: address1.String(), + Denom: testDenom, + PublicKey: sourceKeypair.PublicKey.ToAffineCompressed(), + DecryptableBalance: decryptableBalance, + Proofs: proofsProto, + } + + assert.NoError(t, m.ValidateBasic()) + + marshalled, err := m.Marshal() + require.NoError(t, err) + + // Reset the message + m = &MsgInitializeAccount{} + err = m.Unmarshal(marshalled) + require.NoError(t, err) + + assert.NoError(t, m.ValidateBasic()) + + result, err := m.FromProto() + + assert.NoError(t, err) + assert.Equal(t, m.FromAddress, result.FromAddress) + assert.Equal(t, m.Denom, result.Denom) + assert.Equal(t, m.DecryptableBalance, result.DecryptableBalance) + assert.Equal(t, m.PublicKey, result.Pubkey) + + decryptedRemainingBalance, err := encryption.DecryptAESGCM(result.DecryptableBalance, aesPK) + assert.NoError(t, err) + + assert.Equal(t, uint64(0), decryptedRemainingBalance) + + // Make sure the proofs are valid + assert.True(t, zkproofs.VerifyPubKeyValidity( + *result.Pubkey, + *result.Proofs.PubkeyValidityProof)) +} + +func TestMsgInitializeAccount_ValidateBasic(t *testing.T) { + validAddress := sdk.AccAddress("address1").String() + invalidAddress := "invalid_address" + validDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + + tests := []struct { + name string + msg MsgInitializeAccount + wantErr bool + errMsg string + }{ + { + name: "invalid from address", + msg: MsgInitializeAccount{ + FromAddress: invalidAddress, + Denom: validDenom, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidAddress.Error(), + }, + { + name: "invalid denom", + msg: MsgInitializeAccount{ + FromAddress: validAddress, + Denom: "", + }, + wantErr: true, + errMsg: "invalid denom", + }, + { + name: "missing pubkey", + msg: MsgInitializeAccount{ + FromAddress: validAddress, + Denom: validDenom, + PublicKey: nil, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + { + name: "missing proofs", + msg: MsgInitializeAccount{ + FromAddress: validAddress, + Denom: validDenom, + PublicKey: curves.ED25519().Point.Random(crand.Reader).ToAffineCompressed(), + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/confidentialtransfers/types/transfer.go b/x/confidentialtransfers/types/transfer.go index 495384786a..cde9d3107a 100644 --- a/x/confidentialtransfers/types/transfer.go +++ b/x/confidentialtransfers/types/transfer.go @@ -15,11 +15,11 @@ type Transfer struct { RecipientTransferAmountHi *elgamal.Ciphertext `json:"recipient_transfer_amount_hi"` RemainingBalanceCommitment *elgamal.Ciphertext `json:"remaining_balance_commitment"` DecryptableBalance string `json:"decryptable_balance"` - Proofs *Proofs `json:"proofs"` + Proofs *TransferProofs `json:"proofs"` Auditors []*TransferAuditor `json:"auditors,omitempty"` //optional field } -type Proofs struct { +type TransferProofs struct { RemainingBalanceCommitmentValidityProof *zkproofs.CiphertextValidityProof `json:"remaining_balance_commitment_validity_proof"` SenderTransferAmountLoValidityProof *zkproofs.CiphertextValidityProof `json:"sender_transfer_amount_lo_validity_proof"` SenderTransferAmountHiValidityProof *zkproofs.CiphertextValidityProof `json:"sender_transfer_amount_hi_validity_proof"` diff --git a/x/confidentialtransfers/types/tx.pb.go b/x/confidentialtransfers/types/tx.pb.go index 96e00c8a58..874e171be6 100644 --- a/x/confidentialtransfers/types/tx.pb.go +++ b/x/confidentialtransfers/types/tx.pb.go @@ -30,17 +30,17 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgTransfer represents a message to send coins from one account to another. type MsgTransfer struct { - FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` - ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty" yaml:"to_address"` - Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` - FromAmountLo *Ciphertext `protobuf:"bytes,4,opt,name=from_amount_lo,json=fromAmountLo,proto3" json:"from_amount_lo,omitempty" yaml:"from_amount_lo"` - FromAmountHi *Ciphertext `protobuf:"bytes,5,opt,name=from_amount_hi,json=fromAmountHi,proto3" json:"from_amount_hi,omitempty" yaml:"from_amount_hi"` - ToAmountLo *Ciphertext `protobuf:"bytes,6,opt,name=to_amount_lo,json=toAmountLo,proto3" json:"to_amount_lo,omitempty" yaml:"to_amount_lo"` - ToAmountHi *Ciphertext `protobuf:"bytes,7,opt,name=to_amount_hi,json=toAmountHi,proto3" json:"to_amount_hi,omitempty" yaml:"to_amount_hi"` - RemainingBalance *Ciphertext `protobuf:"bytes,8,opt,name=remaining_balance,json=remainingBalance,proto3" json:"remaining_balance,omitempty" yaml:"decryptable_balance"` - DecryptableBalance string `protobuf:"bytes,9,opt,name=decryptable_balance,json=decryptableBalance,proto3" json:"decryptable_balance,omitempty" yaml:"decryptable_balance"` - Proofs *TransferProofs `protobuf:"bytes,10,opt,name=proofs,proto3" json:"proofs,omitempty" yaml:"proofs"` - Auditors []*Auditor `protobuf:"bytes,11,rep,name=auditors,proto3" json:"auditors,omitempty" yaml:"auditors"` + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` + ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty" yaml:"to_address"` + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + FromAmountLo *Ciphertext `protobuf:"bytes,4,opt,name=from_amount_lo,json=fromAmountLo,proto3" json:"from_amount_lo,omitempty" yaml:"from_amount_lo"` + FromAmountHi *Ciphertext `protobuf:"bytes,5,opt,name=from_amount_hi,json=fromAmountHi,proto3" json:"from_amount_hi,omitempty" yaml:"from_amount_hi"` + ToAmountLo *Ciphertext `protobuf:"bytes,6,opt,name=to_amount_lo,json=toAmountLo,proto3" json:"to_amount_lo,omitempty" yaml:"to_amount_lo"` + ToAmountHi *Ciphertext `protobuf:"bytes,7,opt,name=to_amount_hi,json=toAmountHi,proto3" json:"to_amount_hi,omitempty" yaml:"to_amount_hi"` + RemainingBalance *Ciphertext `protobuf:"bytes,8,opt,name=remaining_balance,json=remainingBalance,proto3" json:"remaining_balance,omitempty" yaml:"decryptable_balance"` + DecryptableBalance string `protobuf:"bytes,9,opt,name=decryptable_balance,json=decryptableBalance,proto3" json:"decryptable_balance,omitempty" yaml:"decryptable_balance"` + Proofs *TransferMsgProofs `protobuf:"bytes,10,opt,name=proofs,proto3" json:"proofs,omitempty" yaml:"proofs"` + Auditors []*Auditor `protobuf:"bytes,11,rep,name=auditors,proto3" json:"auditors,omitempty" yaml:"auditors"` } func (m *MsgTransfer) Reset() { *m = MsgTransfer{} } @@ -76,7 +76,7 @@ func (m *MsgTransfer) XXX_DiscardUnknown() { var xxx_messageInfo_MsgTransfer proto.InternalMessageInfo -// MsgSendResponse defines the Msg/Send response type. +// MsgTransferResponse defines the Msg/Send response type. type MsgTransferResponse struct { } @@ -205,65 +205,254 @@ func (m *Auditor) GetTransferAmountHiEqualityProof() *CiphertextCiphertextEquali return nil } +// MsgInitializeAccount represents a message to create a new confidential transfer account. +type MsgInitializeAccount struct { + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + PublicKey []byte `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty" yaml:"public_key"` + DecryptableBalance string `protobuf:"bytes,4,opt,name=decryptable_balance,json=decryptableBalance,proto3" json:"decryptable_balance,omitempty" yaml:"decryptable_balance"` + Proofs *InitializeAccountMsgProofs `protobuf:"bytes,5,opt,name=proofs,proto3" json:"proofs,omitempty" yaml:"proofs"` +} + +func (m *MsgInitializeAccount) Reset() { *m = MsgInitializeAccount{} } +func (m *MsgInitializeAccount) String() string { return proto.CompactTextString(m) } +func (*MsgInitializeAccount) ProtoMessage() {} +func (*MsgInitializeAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_34e86c2ca2c678f9, []int{3} +} +func (m *MsgInitializeAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgInitializeAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgInitializeAccount.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgInitializeAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInitializeAccount.Merge(m, src) +} +func (m *MsgInitializeAccount) XXX_Size() int { + return m.Size() +} +func (m *MsgInitializeAccount) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInitializeAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgInitializeAccount proto.InternalMessageInfo + +// MsgInitializeAccountResponse defines the Msg/Send response type. +type MsgInitializeAccountResponse struct { +} + +func (m *MsgInitializeAccountResponse) Reset() { *m = MsgInitializeAccountResponse{} } +func (m *MsgInitializeAccountResponse) String() string { return proto.CompactTextString(m) } +func (*MsgInitializeAccountResponse) ProtoMessage() {} +func (*MsgInitializeAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_34e86c2ca2c678f9, []int{4} +} +func (m *MsgInitializeAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgInitializeAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgInitializeAccountResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgInitializeAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInitializeAccountResponse.Merge(m, src) +} +func (m *MsgInitializeAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgInitializeAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInitializeAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgInitializeAccountResponse proto.InternalMessageInfo + +// MsgDeposit represents a message for depositing tokens into a confidential account +type MsgDeposit struct { + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty" yaml:"amount"` +} + +func (m *MsgDeposit) Reset() { *m = MsgDeposit{} } +func (m *MsgDeposit) String() string { return proto.CompactTextString(m) } +func (*MsgDeposit) ProtoMessage() {} +func (*MsgDeposit) Descriptor() ([]byte, []int) { + return fileDescriptor_34e86c2ca2c678f9, []int{5} +} +func (m *MsgDeposit) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeposit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeposit.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeposit) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeposit.Merge(m, src) +} +func (m *MsgDeposit) XXX_Size() int { + return m.Size() +} +func (m *MsgDeposit) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeposit.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeposit proto.InternalMessageInfo + +func (m *MsgDeposit) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *MsgDeposit) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *MsgDeposit) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +// MsgDepositResponse defines the Msg/Send response type. +type MsgDepositResponse struct { +} + +func (m *MsgDepositResponse) Reset() { *m = MsgDepositResponse{} } +func (m *MsgDepositResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDepositResponse) ProtoMessage() {} +func (*MsgDepositResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_34e86c2ca2c678f9, []int{6} +} +func (m *MsgDepositResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDepositResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDepositResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDepositResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDepositResponse.Merge(m, src) +} +func (m *MsgDepositResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDepositResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDepositResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDepositResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgTransfer)(nil), "seiprotocol.seichain.confidentialtransfers.MsgTransfer") proto.RegisterType((*MsgTransferResponse)(nil), "seiprotocol.seichain.confidentialtransfers.MsgTransferResponse") proto.RegisterType((*Auditor)(nil), "seiprotocol.seichain.confidentialtransfers.Auditor") + proto.RegisterType((*MsgInitializeAccount)(nil), "seiprotocol.seichain.confidentialtransfers.MsgInitializeAccount") + proto.RegisterType((*MsgInitializeAccountResponse)(nil), "seiprotocol.seichain.confidentialtransfers.MsgInitializeAccountResponse") + proto.RegisterType((*MsgDeposit)(nil), "seiprotocol.seichain.confidentialtransfers.MsgDeposit") + proto.RegisterType((*MsgDepositResponse)(nil), "seiprotocol.seichain.confidentialtransfers.MsgDepositResponse") } func init() { proto.RegisterFile("confidentialtransfers/tx.proto", fileDescriptor_34e86c2ca2c678f9) } var fileDescriptor_34e86c2ca2c678f9 = []byte{ - // 771 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x3f, 0x6f, 0xd3, 0x4c, - 0x18, 0x8f, 0xdb, 0xb7, 0x6d, 0x72, 0xe9, 0xdb, 0x3f, 0xce, 0x5b, 0xbd, 0x6e, 0x04, 0x76, 0x39, - 0x24, 0x88, 0x10, 0x24, 0x52, 0x8b, 0x40, 0x0a, 0x43, 0xd5, 0x54, 0x48, 0x19, 0xa8, 0x40, 0x16, - 0x42, 0x82, 0x25, 0x72, 0xe2, 0x4b, 0x7c, 0xc2, 0xf1, 0xa5, 0xbe, 0x0b, 0x34, 0xac, 0x30, 0x30, - 0x30, 0x30, 0x32, 0xf6, 0x0b, 0xf0, 0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0x4f, 0x5d, 0x89, 0xfa, 0x31, 0xde, - 0x31, 0xf5, 0x75, 0x9c, 0x54, 0xff, 0x3d, 0xbd, 0xf6, 0x68, 0xbb, 0x6f, 0xd8, 0x87, 0xea, 0xc5, - 0x2c, 0xdf, 0x3a, 0x9f, 0xfa, 0xc3, 0xaf, 0xc7, 0x01, 0xea, 0x69, 0x6e, 0x21, 0xa9, 0x20, 0xe5, - 0x16, 0x12, 0x60, 0xa9, 0x3e, 0x2c, 0x3c, 0xea, 0x63, 0xe6, 0x8a, 0x7d, 0x8c, 0x29, 0x48, 0xb9, - 0x8f, 0x04, 0xd8, 0xea, 0x27, 0x09, 0x4c, 0x6e, 0xd1, 0x8e, 0xfc, 0x41, 0x02, 0xd9, 0xe8, 0x37, - 0xe7, 0xe1, 0x59, 0x04, 0xc7, 0x06, 0x5e, 0x71, 0xfd, 0x9c, 0x89, 0xe1, 0xa4, 0xac, 0xbd, 0xfc, - 0xb1, 0xaf, 0x4a, 0x7b, 0xfb, 0xaa, 0xf4, 0x6b, 0x5f, 0x95, 0x3e, 0x1f, 0xa8, 0x99, 0xbd, 0x03, - 0x35, 0xf3, 0xf3, 0x40, 0xcd, 0xbc, 0x5a, 0xef, 0x60, 0x66, 0xf5, 0x9b, 0xe5, 0x16, 0xe9, 0x56, - 0x28, 0xc2, 0xf7, 0x42, 0x16, 0xbe, 0xe0, 0x34, 0x95, 0x9d, 0xca, 0x11, 0xbf, 0x96, 0x83, 0x1e, - 0xa2, 0xcd, 0x69, 0x9e, 0xb1, 0xf6, 0x27, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x01, 0x76, 0xea, 0x80, - 0x0a, 0x00, 0x00, + // 902 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcf, 0x6f, 0xe3, 0x44, + 0x14, 0x8e, 0xd3, 0x36, 0x4d, 0x26, 0xa1, 0xbb, 0x75, 0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df, 0x46, 0x31, 0x38, 0x54, 0xef, 0x27, 0x84, 0x6d, 0x3e, 0x25, 0x7e, + 0x0e, 0xaa, 0x19, 0x3b, 0xa5, 0x12, 0xbb, 0x93, 0xd7, 0xc1, 0x89, 0xa9, 0xd9, 0x18, 0xd0, 0x02, + 0x05, 0xd7, 0x23, 0x64, 0x40, 0x25, 0xc0, 0x5c, 0xf9, 0x60, 0x15, 0x57, 0xe2, 0x74, 0xec, 0x52, + 0xf3, 0x0b, 0x06, 0xd2, 0xde, 0x0f, 0x03, 0xe5, 0x25, 0x2e, 0x81, 0xc3, 0x42, 0x35, 0xc2, 0x17, + 0x0d, 0x50, 0xd4, 0x46, 0x06, 0xf6, 0x89, 0x47, 0xa5, 0xf2, 0xd1, 0x56, 0xbd, 0x7c, 0xfc, 0x68, + 0x15, 0xae, 0x16, 0xb7, 0x6d, 0x57, 0xc3, 0x40, 0xb9, 0xc7, 0x19, 0x62, 0x38, 0xa8, 0x26, 0xc8, + 0x27, 0xc5, 0x1f, 0xcf, 0x95, 0xdc, 0x3f, 0xe7, 0x4a, 0x0e, 0x1e, 0x82, 0x6a, 0xaa, 0x62, 0xa8, + 0x88, 0xba, 0xc4, 0xa1, 0x08, 0xfe, 0x52, 0x02, 0xbb, 0x11, 0x96, 0xf8, 0x3e, 0xb8, 0x17, 0x19, + 0xce, 0x15, 0x12, 0x31, 0x0c, 0x94, 0xbd, 0x88, 0x24, 0xae, 0x05, 0x7b, 0xd1, 0xd6, 0xb8, 0x20, + 0x9c, 0x0b, 0xe0, 0x21, 0x72, 0x58, 0x40, 0x91, 0xd1, 0x8b, 0x85, 0xa6, 0xf2, 0x20, 0xbf, 0xd1, + 0xdd, 0x78, 0x23, 0x0c, 0x94, 0xd7, 0xb8, 0x84, 0xab, 0x58, 0xa0, 0xfa, 0x20, 0x59, 0x8e, 0x7d, + 0x4d, 0xd2, 0xe4, 0x6a, 0x89, 0x16, 0x66, 0xb5, 0xec, 0x96, 0x25, 0x4e, 0xf2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 0xce, 0x6b, 0x21, 0x72, 0x37, 0x69, 0x4c, 0xa9, 0x96, 0x21, 0x83, 0x87, 0x59, 0xf1, 0x4f, + 0x7a, 0xc7, 0xaf, 0x02, 0x00, 0x5d, 0x6a, 0x7e, 0x88, 0x5c, 0x42, 0xf1, 0xdd, 0x1c, 0xcb, 0x9b, + 0xa0, 0xc0, 0xef, 0x13, 0x3b, 0x92, 0xed, 0xb4, 0x1f, 0x7c, 0x1e, 0xaa, 0xd1, 0x06, 0x78, 0x00, + 0xc4, 0xa9, 0xb8, 0x58, 0xf3, 0xf1, 0x4f, 0x02, 0xd8, 0xea, 0x52, 0x53, 0xfc, 0x41, 0x00, 0xc5, + 0xe4, 0xf9, 0xfc, 0xde, 0x2a, 0x51, 0x4d, 0x75, 0xd1, 0xda, 0x93, 0x35, 0x0d, 0x63, 0x39, 0xed, + 0xaf, 0xff, 0xbc, 0x90, 0x85, 0x17, 0x17, 0xb2, 0xf0, 0xf7, 0x85, 0x2c, 0xfc, 0x7c, 0x29, 0xe7, + 0x5e, 0x5c, 0xca, 0xb9, 0xbf, 0x2e, 0xe5, 0xdc, 0x37, 0x4f, 0x4c, 0xec, 0x5b, 0xa3, 0x7e, 0x43, + 0x27, 0xc3, 0x26, 0x45, 0xf8, 0x9d, 0x98, 0x85, 0x0d, 0x18, 0x4d, 0xf3, 0xac, 0xb9, 0xe4, 0x97, + 0x65, 0xec, 0x22, 0xda, 0x2f, 0x30, 0x8b, 0x47, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x92, 0x09, + 0x52, 0x62, 0xd8, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -610,6 +799,157 @@ func (m *Auditor) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgInitializeAccount) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgInitializeAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgInitializeAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proofs != nil { + { + size, err := m.Proofs.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.DecryptableBalance) > 0 { + i -= len(m.DecryptableBalance) + copy(dAtA[i:], m.DecryptableBalance) + i = encodeVarintTx(dAtA, i, uint64(len(m.DecryptableBalance))) + i-- + dAtA[i] = 0x22 + } + if len(m.PublicKey) > 0 { + i -= len(m.PublicKey) + copy(dAtA[i:], m.PublicKey) + i = encodeVarintTx(dAtA, i, uint64(len(m.PublicKey))) + i-- + dAtA[i] = 0x1a + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgInitializeAccountResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgInitializeAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgInitializeAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeposit) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeposit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeposit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Amount != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDepositResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDepositResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDepositResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -722,32 +1062,99 @@ func (m *Auditor) Size() (n int) { return n } -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgTransfer) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } +func (m *MsgInitializeAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PublicKey) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.DecryptableBalance) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Proofs != nil { + l = m.Proofs.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgInitializeAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeposit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Amount != 0 { + n += 1 + sovTx(uint64(m.Amount)) + } + return n +} + +func (m *MsgDepositResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgTransfer) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { @@ -1095,7 +1502,7 @@ func (m *MsgTransfer) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Proofs == nil { - m.Proofs = &TransferProofs{} + m.Proofs = &TransferMsgProofs{} } if err := m.Proofs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1504,6 +1911,455 @@ func (m *Auditor) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgInitializeAccount) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgInitializeAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInitializeAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FromAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PublicKey = append(m.PublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.PublicKey == nil { + m.PublicKey = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecryptableBalance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DecryptableBalance = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proofs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Proofs == nil { + m.Proofs = &InitializeAccountMsgProofs{} + } + if err := m.Proofs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgInitializeAccountResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgInitializeAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInitializeAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeposit) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeposit: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeposit: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FromAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDepositResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDepositResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDepositResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/confidentialtransfers/types/zk.go b/x/confidentialtransfers/types/zk.go index d05c039fd9..c6398a7d24 100644 --- a/x/confidentialtransfers/types/zk.go +++ b/x/confidentialtransfers/types/zk.go @@ -1,14 +1,14 @@ package types import ( - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/coinbase/kryptology/pkg/bulletproof" "github.com/coinbase/kryptology/pkg/core/curves" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/sei-protocol/sei-cryptography/pkg/zkproofs" ) -func (c *TransferProofs) Validate() error { +func (c *TransferMsgProofs) Validate() error { if c.RemainingBalanceCommitmentValidityProof == nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "remaining balance commitment validity proof is required") } @@ -48,8 +48,8 @@ func (c *TransferProofs) Validate() error { return nil } -func (c *TransferProofs) ToProto(proofs *Proofs) *TransferProofs { - return &TransferProofs{ +func (c *TransferMsgProofs) ToProto(proofs *TransferProofs) *TransferMsgProofs { + return &TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: c.RemainingBalanceCommitmentValidityProof.ToProto(proofs.RemainingBalanceCommitmentValidityProof), SenderTransferAmountLoValidityProof: c.RemainingBalanceCommitmentValidityProof.ToProto(proofs.SenderTransferAmountLoValidityProof), SenderTransferAmountHiValidityProof: c.RemainingBalanceCommitmentValidityProof.ToProto(proofs.SenderTransferAmountHiValidityProof), @@ -62,7 +62,7 @@ func (c *TransferProofs) ToProto(proofs *Proofs) *TransferProofs { } } -func (c *TransferProofs) FromProto() (*Proofs, error) { +func (c *TransferMsgProofs) FromProto() (*TransferProofs, error) { err := c.Validate() if err != nil { return nil, err @@ -112,7 +112,7 @@ func (c *TransferProofs) FromProto() (*Proofs, error) { return nil, err } - return &Proofs{ + return &TransferProofs{ RemainingBalanceCommitmentValidityProof: remainingBalanceCommitmentValidityProof, SenderTransferAmountLoValidityProof: senderTransferAmountLoValidityProof, SenderTransferAmountHiValidityProof: senderTransferAmountHiValidityProof, @@ -125,6 +125,36 @@ func (c *TransferProofs) FromProto() (*Proofs, error) { }, nil } +func (c *InitializeAccountMsgProofs) Validate() error { + if c.PubkeyValidityProof == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "pubkey validity proof is required") + } + + return nil +} + +func NewInitializeAccountMsgProofs(proofs *InitializeAccountProofs) *InitializeAccountMsgProofs { + return &InitializeAccountMsgProofs{ + PubkeyValidityProof: NewPubkeyValidityProofProto(proofs.PubkeyValidityProof), + } +} + +func (c *InitializeAccountMsgProofs) FromProto() (*InitializeAccountProofs, error) { + err := c.Validate() + if err != nil { + return nil, err + } + + pubkeyValidityProof, err := c.PubkeyValidityProof.FromProto() + if err != nil { + return nil, err + } + + return &InitializeAccountProofs{ + PubkeyValidityProof: pubkeyValidityProof, + }, nil +} + func (c *CiphertextValidityProof) Validate() error { if c.Commitment_1 == nil || c.Commitment_2 == nil || c.Response_1 == nil || c.Response_2 == nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "ciphertext validity proof is invalid") @@ -418,3 +448,40 @@ func (a *Auditor) FromProto() (*TransferAuditor, error) { TransferAmountHiEqualityProof: transferAmountHiEqualityProof, }, nil } + +func (p *PubkeyValidityProof) Validate() error { + if p.Y == nil || p.Z == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "pubkey validity proof is invalid") + } + return nil +} + +func NewPubkeyValidityProofProto(zkp *zkproofs.PubKeyValidityProof) *PubkeyValidityProof { + return &PubkeyValidityProof{ + Y: zkp.Y.ToAffineCompressed(), + Z: zkp.Z.Bytes(), + } +} + +func (p *PubkeyValidityProof) FromProto() (*zkproofs.PubKeyValidityProof, error) { + err := p.Validate() + if err != nil { + return nil, err + } + ed25519Curve := curves.ED25519() + + y, err := ed25519Curve.Point.FromAffineCompressed(p.Y) + if err != nil { + return nil, err + } + + z, err := ed25519Curve.Scalar.SetBytes(p.Z) + if err != nil { + return nil, err + } + + return &zkproofs.PubKeyValidityProof{ + Y: y, + Z: z, + }, nil +} diff --git a/x/confidentialtransfers/types/zk.pb.go b/x/confidentialtransfers/types/zk.pb.go index b4480aa450..1ed654a8d8 100644 --- a/x/confidentialtransfers/types/zk.pb.go +++ b/x/confidentialtransfers/types/zk.pb.go @@ -22,7 +22,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type TransferProofs struct { +type TransferMsgProofs struct { RemainingBalanceCommitmentValidityProof *CiphertextValidityProof `protobuf:"bytes,1,opt,name=remaining_balance_commitment_validity_proof,json=remainingBalanceCommitmentValidityProof,proto3" json:"remaining_balance_commitment_validity_proof,omitempty"` SenderTransferAmountLoValidityProof *CiphertextValidityProof `protobuf:"bytes,2,opt,name=sender_transfer_amount_lo_validity_proof,json=senderTransferAmountLoValidityProof,proto3" json:"sender_transfer_amount_lo_validity_proof,omitempty"` SenderTransferAmountHiValidityProof *CiphertextValidityProof `protobuf:"bytes,3,opt,name=sender_transfer_amount_hi_validity_proof,json=senderTransferAmountHiValidityProof,proto3" json:"sender_transfer_amount_hi_validity_proof,omitempty"` @@ -34,18 +34,18 @@ type TransferProofs struct { TransferAmountHiEqualityProof *CiphertextCiphertextEqualityProof `protobuf:"bytes,9,opt,name=transfer_amount_hi_equality_proof,json=transferAmountHiEqualityProof,proto3" json:"transfer_amount_hi_equality_proof,omitempty"` } -func (m *TransferProofs) Reset() { *m = TransferProofs{} } -func (m *TransferProofs) String() string { return proto.CompactTextString(m) } -func (*TransferProofs) ProtoMessage() {} -func (*TransferProofs) Descriptor() ([]byte, []int) { +func (m *TransferMsgProofs) Reset() { *m = TransferMsgProofs{} } +func (m *TransferMsgProofs) String() string { return proto.CompactTextString(m) } +func (*TransferMsgProofs) ProtoMessage() {} +func (*TransferMsgProofs) Descriptor() ([]byte, []int) { return fileDescriptor_71d8640cbb42ddec, []int{0} } -func (m *TransferProofs) XXX_Unmarshal(b []byte) error { +func (m *TransferMsgProofs) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *TransferProofs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *TransferMsgProofs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_TransferProofs.Marshal(b, m, deterministic) + return xxx_messageInfo_TransferMsgProofs.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,81 +55,177 @@ func (m *TransferProofs) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } -func (m *TransferProofs) XXX_Merge(src proto.Message) { - xxx_messageInfo_TransferProofs.Merge(m, src) +func (m *TransferMsgProofs) XXX_Merge(src proto.Message) { + xxx_messageInfo_TransferMsgProofs.Merge(m, src) } -func (m *TransferProofs) XXX_Size() int { +func (m *TransferMsgProofs) XXX_Size() int { return m.Size() } -func (m *TransferProofs) XXX_DiscardUnknown() { - xxx_messageInfo_TransferProofs.DiscardUnknown(m) +func (m *TransferMsgProofs) XXX_DiscardUnknown() { + xxx_messageInfo_TransferMsgProofs.DiscardUnknown(m) } -var xxx_messageInfo_TransferProofs proto.InternalMessageInfo +var xxx_messageInfo_TransferMsgProofs proto.InternalMessageInfo -func (m *TransferProofs) GetRemainingBalanceCommitmentValidityProof() *CiphertextValidityProof { +func (m *TransferMsgProofs) GetRemainingBalanceCommitmentValidityProof() *CiphertextValidityProof { if m != nil { return m.RemainingBalanceCommitmentValidityProof } return nil } -func (m *TransferProofs) GetSenderTransferAmountLoValidityProof() *CiphertextValidityProof { +func (m *TransferMsgProofs) GetSenderTransferAmountLoValidityProof() *CiphertextValidityProof { if m != nil { return m.SenderTransferAmountLoValidityProof } return nil } -func (m *TransferProofs) GetSenderTransferAmountHiValidityProof() *CiphertextValidityProof { +func (m *TransferMsgProofs) GetSenderTransferAmountHiValidityProof() *CiphertextValidityProof { if m != nil { return m.SenderTransferAmountHiValidityProof } return nil } -func (m *TransferProofs) GetRecipientTransferAmountLoValidityProof() *CiphertextValidityProof { +func (m *TransferMsgProofs) GetRecipientTransferAmountLoValidityProof() *CiphertextValidityProof { if m != nil { return m.RecipientTransferAmountLoValidityProof } return nil } -func (m *TransferProofs) GetRecipientTransferAmountHiValidityProof() *CiphertextValidityProof { +func (m *TransferMsgProofs) GetRecipientTransferAmountHiValidityProof() *CiphertextValidityProof { if m != nil { return m.RecipientTransferAmountHiValidityProof } return nil } -func (m *TransferProofs) GetRemainingBalanceRangeProof() *RangeProof { +func (m *TransferMsgProofs) GetRemainingBalanceRangeProof() *RangeProof { if m != nil { return m.RemainingBalanceRangeProof } return nil } -func (m *TransferProofs) GetRemainingBalanceEqualityProof() *CiphertextCommitmentEqualityProof { +func (m *TransferMsgProofs) GetRemainingBalanceEqualityProof() *CiphertextCommitmentEqualityProof { if m != nil { return m.RemainingBalanceEqualityProof } return nil } -func (m *TransferProofs) GetTransferAmountLoEqualityProof() *CiphertextCiphertextEqualityProof { +func (m *TransferMsgProofs) GetTransferAmountLoEqualityProof() *CiphertextCiphertextEqualityProof { if m != nil { return m.TransferAmountLoEqualityProof } return nil } -func (m *TransferProofs) GetTransferAmountHiEqualityProof() *CiphertextCiphertextEqualityProof { +func (m *TransferMsgProofs) GetTransferAmountHiEqualityProof() *CiphertextCiphertextEqualityProof { if m != nil { return m.TransferAmountHiEqualityProof } return nil } +type InitializeAccountMsgProofs struct { + PubkeyValidityProof *PubkeyValidityProof `protobuf:"bytes,1,opt,name=pubkey_validity_proof,json=pubkeyValidityProof,proto3" json:"pubkey_validity_proof,omitempty"` +} + +func (m *InitializeAccountMsgProofs) Reset() { *m = InitializeAccountMsgProofs{} } +func (m *InitializeAccountMsgProofs) String() string { return proto.CompactTextString(m) } +func (*InitializeAccountMsgProofs) ProtoMessage() {} +func (*InitializeAccountMsgProofs) Descriptor() ([]byte, []int) { + return fileDescriptor_71d8640cbb42ddec, []int{1} +} +func (m *InitializeAccountMsgProofs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InitializeAccountMsgProofs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InitializeAccountMsgProofs.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *InitializeAccountMsgProofs) XXX_Merge(src proto.Message) { + xxx_messageInfo_InitializeAccountMsgProofs.Merge(m, src) +} +func (m *InitializeAccountMsgProofs) XXX_Size() int { + return m.Size() +} +func (m *InitializeAccountMsgProofs) XXX_DiscardUnknown() { + xxx_messageInfo_InitializeAccountMsgProofs.DiscardUnknown(m) +} + +var xxx_messageInfo_InitializeAccountMsgProofs proto.InternalMessageInfo + +func (m *InitializeAccountMsgProofs) GetPubkeyValidityProof() *PubkeyValidityProof { + if m != nil { + return m.PubkeyValidityProof + } + return nil +} + +type PubkeyValidityProof struct { + Y []byte `protobuf:"bytes,1,opt,name=y,proto3" json:"y,omitempty"` + Z []byte `protobuf:"bytes,2,opt,name=z,proto3" json:"z,omitempty"` +} + +func (m *PubkeyValidityProof) Reset() { *m = PubkeyValidityProof{} } +func (m *PubkeyValidityProof) String() string { return proto.CompactTextString(m) } +func (*PubkeyValidityProof) ProtoMessage() {} +func (*PubkeyValidityProof) Descriptor() ([]byte, []int) { + return fileDescriptor_71d8640cbb42ddec, []int{2} +} +func (m *PubkeyValidityProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubkeyValidityProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubkeyValidityProof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PubkeyValidityProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubkeyValidityProof.Merge(m, src) +} +func (m *PubkeyValidityProof) XXX_Size() int { + return m.Size() +} +func (m *PubkeyValidityProof) XXX_DiscardUnknown() { + xxx_messageInfo_PubkeyValidityProof.DiscardUnknown(m) +} + +var xxx_messageInfo_PubkeyValidityProof proto.InternalMessageInfo + +func (m *PubkeyValidityProof) GetY() []byte { + if m != nil { + return m.Y + } + return nil +} + +func (m *PubkeyValidityProof) GetZ() []byte { + if m != nil { + return m.Z + } + return nil +} + type CiphertextValidityProof struct { // First commitment Commitment_1 []byte `protobuf:"bytes,1,opt,name=commitment_1,json=commitment1,proto3" json:"commitment_1,omitempty"` @@ -145,7 +241,7 @@ func (m *CiphertextValidityProof) Reset() { *m = CiphertextValidityProof func (m *CiphertextValidityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextValidityProof) ProtoMessage() {} func (*CiphertextValidityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{1} + return fileDescriptor_71d8640cbb42ddec, []int{3} } func (m *CiphertextValidityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,7 +308,7 @@ func (m *RangeProof) Reset() { *m = RangeProof{} } func (m *RangeProof) String() string { return proto.CompactTextString(m) } func (*RangeProof) ProtoMessage() {} func (*RangeProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{2} + return fileDescriptor_71d8640cbb42ddec, []int{4} } func (m *RangeProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -275,7 +371,7 @@ func (m *CiphertextCommitmentEqualityProof) Reset() { *m = CiphertextCom func (m *CiphertextCommitmentEqualityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextCommitmentEqualityProof) ProtoMessage() {} func (*CiphertextCommitmentEqualityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{3} + return fileDescriptor_71d8640cbb42ddec, []int{5} } func (m *CiphertextCommitmentEqualityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -360,7 +456,7 @@ func (m *CiphertextCiphertextEqualityProof) Reset() { *m = CiphertextCip func (m *CiphertextCiphertextEqualityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextCiphertextEqualityProof) ProtoMessage() {} func (*CiphertextCiphertextEqualityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{4} + return fileDescriptor_71d8640cbb42ddec, []int{6} } func (m *CiphertextCiphertextEqualityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -439,7 +535,9 @@ func (m *CiphertextCiphertextEqualityProof) GetZr() []byte { } func init() { - proto.RegisterType((*TransferProofs)(nil), "seiprotocol.seichain.confidentialtransfers.TransferProofs") + proto.RegisterType((*TransferMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.TransferMsgProofs") + proto.RegisterType((*InitializeAccountMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.InitializeAccountMsgProofs") + proto.RegisterType((*PubkeyValidityProof)(nil), "seiprotocol.seichain.confidentialtransfers.PubkeyValidityProof") proto.RegisterType((*CiphertextValidityProof)(nil), "seiprotocol.seichain.confidentialtransfers.CiphertextValidityProof") proto.RegisterType((*RangeProof)(nil), "seiprotocol.seichain.confidentialtransfers.RangeProof") proto.RegisterType((*CiphertextCommitmentEqualityProof)(nil), "seiprotocol.seichain.confidentialtransfers.CiphertextCommitmentEqualityProof") @@ -449,49 +547,53 @@ func init() { func init() { proto.RegisterFile("confidentialtransfers/zk.proto", fileDescriptor_71d8640cbb42ddec) } var fileDescriptor_71d8640cbb42ddec = []byte{ - // 617 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x96, 0xc1, 0x8b, 0xd3, 0x4e, - 0x14, 0xc7, 0x77, 0xb2, 0xbf, 0xed, 0xfe, 0x76, 0x5a, 0xf6, 0x10, 0x04, 0x45, 0x68, 0xdc, 0x56, - 0xd0, 0x45, 0x31, 0xdd, 0xa4, 0xe0, 0x55, 0x6c, 0x11, 0xf6, 0xa0, 0x20, 0x41, 0x04, 0xbd, 0x84, - 0x69, 0x3a, 0x6d, 0x07, 0x93, 0x99, 0x38, 0x33, 0x95, 0xa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00, 0xff, - 0xff, 0x62, 0x8c, 0x5f, 0x27, 0x4f, 0x08, 0x00, 0x00, -} - -func (m *TransferProofs) Marshal() (dAtA []byte, err error) { + // 680 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x96, 0x5d, 0x6b, 0x13, 0x4d, + 0x14, 0xc7, 0x3b, 0xe9, 0xd3, 0xf6, 0xe9, 0x69, 0x10, 0xdc, 0x2a, 0x4a, 0xa1, 0x6b, 0xbb, 0x82, + 0x16, 0xc5, 0xa4, 0xbb, 0x05, 0x6f, 0x4b, 0x5b, 0x84, 0x0a, 0x16, 0xca, 0x22, 0x82, 0xde, 0x2c, + 0x9b, 0xcd, 0x34, 0x19, 0x9a, 0x9d, 0x59, 0x67, 0x26, 0x92, 0xdd, 0x5b, 0xbf, 0x80, 0x22, 0x28, + 0x08, 0x82, 0x7e, 0x1b, 0x2f, 0x7b, 0xe9, 0xa5, 0xb4, 0x1f, 0x44, 0xd9, 0xc9, 0xe4, 0x65, 0x27, + 0xb1, 0x69, 0x6b, 0xeb, 0xdd, 0xfe, 0xe7, 0xe5, 0xfc, 0x7f, 0x7b, 0xf6, 0x9c, 0x93, 0x80, 0x1d, + 0x31, 0x7a, 0x40, 0xea, 0x98, 0x4a, 0x12, 0xb6, 0x24, 0x0f, 0xa9, 0x38, 0xc0, 0x5c, 0x54, 0xb3, + 0xc3, 0x4a, 0xc2, 0x99, 0x64, 0xd6, 0x03, 0x81, 0x89, 0x7a, 0x8a, 0x58, 0xab, 0x22, 0x30, 0x89, + 0x9a, 0x21, 0xa1, 0x95, 0xb1, 0x97, 0x9c, 0x5f, 0x00, 0xd7, 0x9f, 0x6b, 0xb5, 0x27, 0x1a, 0xfb, + 0x9c, 0xb1, 0x03, 0x61, 0x7d, 0x43, 0xf0, 0x90, 0xe3, 0x38, 0x24, 0x94, 0xd0, 0x46, 0x50, 0x0b, + 0x5b, 0x21, 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0xeb, + 0x6a, 0x6e, 0x4f, 0xfb, 0xa0, 0x96, 0xb6, 0xf3, 0x15, 0xe7, 0x2d, 0x82, 0xd5, 0x89, 0x4d, 0x64, + 0x5d, 0x83, 0x52, 0xba, 0xae, 0x9d, 0x4b, 0xe9, 0xba, 0xd2, 0xae, 0xb6, 0x2b, 0xa5, 0xae, 0xd2, + 0x9e, 0x8a, 0x9e, 0x6b, 0x2f, 0xd7, 0x99, 0xd0, 0x2f, 0x5c, 0xca, 0x84, 0xd2, 0x1d, 0xfd, 0x86, + 0xa5, 0xac, 0xa3, 0x34, 0x57, 0xe3, 0x26, 0xd7, 0xdc, 0xf9, 0x50, 0xa4, 0x18, 0x5f, 0x96, 0x17, + 0xa1, 0x48, 0x37, 0x7a, 0x14, 0xe9, 0x86, 0xa6, 0x9a, 0x31, 0xa8, 0x66, 0x0d, 0xaa, 0xb9, 0x1e, + 0xd5, 0xf6, 0xcb, 0xef, 0xc7, 0x36, 0x3a, 0x3a, 0xb6, 0xd1, 0xcf, 0x63, 0x1b, 0xbd, 0x3b, 0xb1, + 0xa7, 0x8e, 0x4e, 0xec, 0xa9, 0x1f, 0x27, 0xf6, 0xd4, 0xab, 0xcd, 0x06, 0x91, 0xcd, 0x76, 0xad, + 0x12, 0xb1, 0xb8, 0x2a, 0x30, 0x79, 0xd4, 0x2b, 0x67, 0x25, 0x54, 0x3d, 0x57, 0x3b, 0xd5, 0xf1, + 0xff, 0x79, 0x64, 0x9a, 0x60, 0x51, 0x9b, 0x55, 0x37, 0x36, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, + 0xe1, 0xa1, 0xeb, 0x04, 0x19, 0x09, 0x00, 0x00, +} + +func (m *TransferMsgProofs) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -501,12 +603,12 @@ func (m *TransferProofs) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *TransferProofs) MarshalTo(dAtA []byte) (int, error) { +func (m *TransferMsgProofs) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *TransferProofs) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TransferMsgProofs) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -622,6 +724,78 @@ func (m *TransferProofs) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *InitializeAccountMsgProofs) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *InitializeAccountMsgProofs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InitializeAccountMsgProofs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PubkeyValidityProof != nil { + { + size, err := m.PubkeyValidityProof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintZk(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PubkeyValidityProof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PubkeyValidityProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubkeyValidityProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Z) > 0 { + i -= len(m.Z) + copy(dAtA[i:], m.Z) + i = encodeVarintZk(dAtA, i, uint64(len(m.Z))) + i-- + dAtA[i] = 0x12 + } + if len(m.Y) > 0 { + i -= len(m.Y) + copy(dAtA[i:], m.Y) + i = encodeVarintZk(dAtA, i, uint64(len(m.Y))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *CiphertextValidityProof) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -863,7 +1037,7 @@ func encodeVarintZk(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *TransferProofs) Size() (n int) { +func (m *TransferMsgProofs) Size() (n int) { if m == nil { return 0 } @@ -908,6 +1082,36 @@ func (m *TransferProofs) Size() (n int) { return n } +func (m *InitializeAccountMsgProofs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PubkeyValidityProof != nil { + l = m.PubkeyValidityProof.Size() + n += 1 + l + sovZk(uint64(l)) + } + return n +} + +func (m *PubkeyValidityProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Y) + if l > 0 { + n += 1 + l + sovZk(uint64(l)) + } + l = len(m.Z) + if l > 0 { + n += 1 + l + sovZk(uint64(l)) + } + return n +} + func (m *CiphertextValidityProof) Size() (n int) { if m == nil { return 0 @@ -1029,7 +1233,7 @@ func sovZk(x uint64) (n int) { func sozZk(x uint64) (n int) { return sovZk(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *TransferProofs) Unmarshal(dAtA []byte) error { +func (m *TransferMsgProofs) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1052,10 +1256,10 @@ func (m *TransferProofs) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TransferProofs: wiretype end group for non-group") + return fmt.Errorf("proto: TransferMsgProofs: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TransferProofs: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TransferMsgProofs: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1403,6 +1607,210 @@ func (m *TransferProofs) Unmarshal(dAtA []byte) error { } return nil } +func (m *InitializeAccountMsgProofs) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: InitializeAccountMsgProofs: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InitializeAccountMsgProofs: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubkeyValidityProof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZk + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZk + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PubkeyValidityProof == nil { + m.PubkeyValidityProof = &PubkeyValidityProof{} + } + if err := m.PubkeyValidityProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipZk(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthZk + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PubkeyValidityProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PubkeyValidityProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubkeyValidityProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Y", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthZk + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthZk + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Y = append(m.Y[:0], dAtA[iNdEx:postIndex]...) + if m.Y == nil { + m.Y = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Z", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthZk + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthZk + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Z = append(m.Z[:0], dAtA[iNdEx:postIndex]...) + if m.Z == nil { + m.Z = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipZk(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthZk + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *CiphertextValidityProof) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/confidentialtransfers/types/zk_test.go b/x/confidentialtransfers/types/zk_test.go index 50e35c71cc..63d25a3a06 100644 --- a/x/confidentialtransfers/types/zk_test.go +++ b/x/confidentialtransfers/types/zk_test.go @@ -1,21 +1,22 @@ package types import ( - "testing" - + crand "crypto/rand" + "github.com/coinbase/kryptology/pkg/core/curves" "github.com/stretchr/testify/require" + "testing" ) func TestTransferProofs_Validate(t *testing.T) { tests := []struct { name string - proofs TransferProofs + proofs TransferMsgProofs wantErr bool errMsg string }{ { name: "valid proofs", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -30,13 +31,13 @@ func TestTransferProofs_Validate(t *testing.T) { }, { name: "missing RemainingBalanceCommitmentValidityProof", - proofs: TransferProofs{}, + proofs: TransferMsgProofs{}, wantErr: true, errMsg: "remaining balance commitment validity proof is required", }, { name: "missing SenderTransferAmountLoValidityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, }, wantErr: true, @@ -44,7 +45,7 @@ func TestTransferProofs_Validate(t *testing.T) { }, { name: "missing SenderTransferAmountHiValidityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, }, @@ -53,7 +54,7 @@ func TestTransferProofs_Validate(t *testing.T) { }, { name: "missing RecipientTransferAmountLoValidityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -63,7 +64,7 @@ func TestTransferProofs_Validate(t *testing.T) { }, { name: "missing RecipientTransferAmountHiValidityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -74,7 +75,7 @@ func TestTransferProofs_Validate(t *testing.T) { }, { name: "missing RemainingBalanceRangeProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -86,7 +87,7 @@ func TestTransferProofs_Validate(t *testing.T) { }, { name: "missing RemainingBalanceEqualityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -99,7 +100,7 @@ func TestTransferProofs_Validate(t *testing.T) { }, { name: "missing TransferAmountLoEqualityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -113,7 +114,7 @@ func TestTransferProofs_Validate(t *testing.T) { }, { name: "missing TransferAmountHiEqualityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -141,22 +142,22 @@ func TestTransferProofs_Validate(t *testing.T) { } } -func TestTransferProofs_FromProto(t *testing.T) { +func TestTransferMsgProofs_FromProto(t *testing.T) { tests := []struct { name string - proofs TransferProofs + proofs TransferMsgProofs wantErr bool errMsg string }{ { name: "missing RemainingBalanceCommitmentValidityProof", - proofs: TransferProofs{}, + proofs: TransferMsgProofs{}, wantErr: true, errMsg: "remaining balance commitment validity proof is required", }, { name: "missing SenderTransferAmountLoValidityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, }, wantErr: true, @@ -164,7 +165,7 @@ func TestTransferProofs_FromProto(t *testing.T) { }, { name: "missing SenderTransferAmountHiValidityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, }, @@ -173,7 +174,7 @@ func TestTransferProofs_FromProto(t *testing.T) { }, { name: "missing RecipientTransferAmountLoValidityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -183,7 +184,7 @@ func TestTransferProofs_FromProto(t *testing.T) { }, { name: "missing RecipientTransferAmountHiValidityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -194,7 +195,7 @@ func TestTransferProofs_FromProto(t *testing.T) { }, { name: "missing RemainingBalanceRangeProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -206,7 +207,7 @@ func TestTransferProofs_FromProto(t *testing.T) { }, { name: "missing RemainingBalanceEqualityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -219,7 +220,7 @@ func TestTransferProofs_FromProto(t *testing.T) { }, { name: "missing TransferAmountLoEqualityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -233,7 +234,7 @@ func TestTransferProofs_FromProto(t *testing.T) { }, { name: "missing TransferAmountHiEqualityProof", - proofs: TransferProofs{ + proofs: TransferMsgProofs{ RemainingBalanceCommitmentValidityProof: &CiphertextValidityProof{}, SenderTransferAmountLoValidityProof: &CiphertextValidityProof{}, SenderTransferAmountHiValidityProof: &CiphertextValidityProof{}, @@ -260,3 +261,76 @@ func TestTransferProofs_FromProto(t *testing.T) { }) } } + +func TestInitializeAccountMsgProofs_Validate(t *testing.T) { + tests := []struct { + name string + proofs InitializeAccountMsgProofs + wantErr bool + errMsg string + }{ + { + name: "valid proofs", + proofs: InitializeAccountMsgProofs{ + PubkeyValidityProof: &PubkeyValidityProof{}, + }, + wantErr: false, + }, + { + name: "missing PubkeyValidityProof", + proofs: InitializeAccountMsgProofs{}, + wantErr: true, + errMsg: "pubkey validity proof is required", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.proofs.Validate() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestInitializeAccountMsgProofs_FromProto(t *testing.T) { + tests := []struct { + name string + proofs InitializeAccountMsgProofs + wantErr bool + errMsg string + }{ + { + name: "valid proofs", + proofs: InitializeAccountMsgProofs{ + PubkeyValidityProof: &PubkeyValidityProof{ + Y: curves.ED25519().Point.Random(crand.Reader).ToAffineCompressed(), + Z: curves.ED25519().Scalar.Random(crand.Reader).Bytes(), + }, + }, + wantErr: true, + }, + { + name: "missing PubkeyValidityProof", + proofs: InitializeAccountMsgProofs{}, + wantErr: true, + errMsg: "pubkey validity proof is required", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := tt.proofs.FromProto() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/evm/types/params.pb.go b/x/evm/types/params.pb.go index aa3dfb97c4..8a74acddbc 100644 --- a/x/evm/types/params.pb.go +++ b/x/evm/types/params.pb.go @@ -104,8 +104,76 @@ func (m *Params) GetTargetGasUsedPerBlock() uint64 { return 0 } +type ParamsPreV580 struct { + // string base_denom = 1 [ + // + // (gogoproto.moretags) = "yaml:\"base_denom\"", + // (gogoproto.jsontag) = "base_denom" + // + // ]; + PriorityNormalizer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=priority_normalizer,json=priorityNormalizer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"priority_normalizer" yaml:"priority_normalizer"` + BaseFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_fee_per_gas" yaml:"base_fee_per_gas"` + MinimumFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=minimum_fee_per_gas,json=minimumFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_fee_per_gas" yaml:"minimum_fee_per_gas"` + // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; + // + // string chain_id = 6 [ + // (gogoproto.moretags) = "yaml:\"chain_id\"", + // (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + // (gogoproto.nullable) = false, + // (gogoproto.jsontag) = "chain_id" + // + // ]; + // repeated string whitelisted_codehashes_bank_send = 7 [ + // + // (gogoproto.moretags) = "yaml:\"whitelisted_codehashes_bank_send\"", + // (gogoproto.jsontag) = "whitelisted_codehashes_bank_send" + // + // ]; + WhitelistedCwCodeHashesForDelegateCall [][]byte `protobuf:"bytes,8,rep,name=whitelisted_cw_code_hashes_for_delegate_call,json=whitelistedCwCodeHashesForDelegateCall,proto3" json:"whitelisted_cw_code_hashes_for_delegate_call" yaml:"whitelisted_cw_code_hashes_for_delegate_call"` +} + +func (m *ParamsPreV580) Reset() { *m = ParamsPreV580{} } +func (*ParamsPreV580) ProtoMessage() {} +func (*ParamsPreV580) Descriptor() ([]byte, []int) { + return fileDescriptor_9272f3679901ea94, []int{1} +} +func (m *ParamsPreV580) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsPreV580) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsPreV580.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ParamsPreV580) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsPreV580.Merge(m, src) +} +func (m *ParamsPreV580) XXX_Size() int { + return m.Size() +} +func (m *ParamsPreV580) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsPreV580.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsPreV580 proto.InternalMessageInfo + +func (m *ParamsPreV580) GetWhitelistedCwCodeHashesForDelegateCall() [][]byte { + if m != nil { + return m.WhitelistedCwCodeHashesForDelegateCall + } + return nil +} + func init() { proto.RegisterType((*Params)(nil), "seiprotocol.seichain.evm.Params") + proto.RegisterType((*ParamsPreV580)(nil), "seiprotocol.seichain.evm.ParamsPreV580") } func init() { proto.RegisterFile("evm/params.proto", fileDescriptor_9272f3679901ea94) } @@ -246,6 +314,68 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ParamsPreV580) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ParamsPreV580) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsPreV580) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { + for iNdEx := len(m.WhitelistedCwCodeHashesForDelegateCall) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) + copy(dAtA[i:], m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]))) + i-- + dAtA[i] = 0x42 + } + } + { + size := m.MinimumFeePerGas.Size() + i -= size + if _, err := m.MinimumFeePerGas.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.BaseFeePerGas.Size() + i -= size + if _, err := m.BaseFeePerGas.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.PriorityNormalizer.Size() + i -= size + if _, err := m.PriorityNormalizer.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + return len(dAtA) - i, nil +} + func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -288,6 +418,27 @@ func (m *Params) Size() (n int) { return n } +func (m *ParamsPreV580) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PriorityNormalizer.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.BaseFeePerGas.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MinimumFeePerGas.Size() + n += 1 + l + sovParams(uint64(l)) + if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { + for _, b := range m.WhitelistedCwCodeHashesForDelegateCall { + l = len(b) + n += 1 + l + sovParams(uint64(l)) + } + } + return n +} + func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -584,7 +735,190 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } +func (m *ParamsPreV580) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ParamsPreV580: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsPreV580: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriorityNormalizer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PriorityNormalizer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseFeePerGas", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BaseFeePerGas.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinimumFeePerGas", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinimumFeePerGas.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedCwCodeHashesForDelegateCall", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhitelistedCwCodeHashesForDelegateCall = append(m.WhitelistedCwCodeHashesForDelegateCall, make([]byte, postIndex-iNdEx)) + copy(m.WhitelistedCwCodeHashesForDelegateCall[len(m.WhitelistedCwCodeHashesForDelegateCall)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 4308770570d524cf04046155f1f3ccb83214a5b7 Mon Sep 17 00:00:00 2001 From: mj Date: Mon, 4 Nov 2024 10:23:05 -0500 Subject: [PATCH 2/8] add deposit to msgs --- x/confidentialtransfers/types/msgs.go | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/x/confidentialtransfers/types/msgs.go b/x/confidentialtransfers/types/msgs.go index f522ed6a45..bdd3e03502 100644 --- a/x/confidentialtransfers/types/msgs.go +++ b/x/confidentialtransfers/types/msgs.go @@ -10,10 +10,12 @@ import ( const ( TypeMsgTransfer = "transfer" TypeMsgInitializeAccount = "initialize_account" + TypeMsgDeposit = "deposit" ) var _ sdk.Msg = &MsgTransfer{} var _ sdk.Msg = &MsgInitializeAccount{} +var _ sdk.Msg = &MsgDeposit{} // Route Implements Msg. func (m *MsgTransfer) Route() string { return RouterKey } @@ -209,3 +211,36 @@ func (m *MsgInitializeAccount) FromProto() (*InitializeAccount, error) { Proofs: proofs, }, nil } + +// Route Implements Msg. +func (m *MsgDeposit) Route() string { return RouterKey } + +// Type Implements Msg. +func (m *MsgDeposit) Type() string { return TypeMsgDeposit } + +func (m *MsgDeposit) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.FromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + err = sdk.ValidateDenom(m.Denom) + if err != nil { + return err + } + + if m.Amount <= 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Positive amount is required") + } + + return nil +} + +func (m *MsgDeposit) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +func (m *MsgDeposit) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.FromAddress) + return []sdk.AccAddress{sender} +} From 23aa4a4bccc88a3758620f39c0b9a0f48635036d Mon Sep 17 00:00:00 2001 From: mj Date: Mon, 4 Nov 2024 10:28:26 -0500 Subject: [PATCH 3/8] add import issues --- go.mod | 7 +++--- go.sum | 23 ++++--------------- .../types/cryptography_test.go | 3 +-- x/confidentialtransfers/types/zk_test.go | 2 +- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index 51d8da5726..b5c5151276 100644 --- a/go.mod +++ b/go.mod @@ -128,7 +128,6 @@ require ( github.com/fzipp/gocyclo v0.5.1 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.3 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -176,7 +175,6 @@ require ( github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect @@ -259,7 +257,7 @@ require ( github.com/regen-network/cosmos-proto v0.3.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.2.0 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/xid v1.5.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/ryancurrah/gomodguard v1.2.3 // indirect @@ -352,6 +350,9 @@ require ( replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.2.4 + + // Replace kryptology library with our fork. + github.com/coinbase/kryptology => github.com/sei-protocol/coinbase-kryptology v0.0.0-20241015231206-08f61b7965cd github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.41 github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0 diff --git a/go.sum b/go.sum index 7896069f84..98d3af535d 100644 --- a/go.sum +++ b/go.sum @@ -291,8 +291,6 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAK github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= -github.com/coinbase/kryptology v1.8.0 h1:Aoq4gdTsJhSU3lNWsD5BWmFSz2pE0GlmrljaOxepdYY= -github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg= github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= @@ -462,7 +460,6 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2Gihuqh github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -771,10 +768,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= @@ -1320,8 +1313,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= @@ -1358,6 +1351,8 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod github.com/securego/gosec/v2 v2.11.0 h1:+PDkpzR41OI2jrw1q6AdXZCbsNGNGT7pQjal0H0cArI= github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+fscA+Pulbpo= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= +github.com/sei-protocol/coinbase-kryptology v0.0.0-20241015231206-08f61b7965cd h1:R/g4pa6pgegLAAt1NTrO1qVJ3uZH9hfcMcc4yLz1cgg= +github.com/sei-protocol/coinbase-kryptology v0.0.0-20241015231206-08f61b7965cd/go.mod h1:vAKKp7/qgfMtPXMseamOlZMqK7BytjfOm0rFKWph5c4= github.com/sei-protocol/go-ethereum v1.13.5-sei-23 h1:rkgeOHC56QTco4mIyGd6cZHtlonulLsaPLZCaMY6TAw= github.com/sei-protocol/go-ethereum v1.13.5-sei-23/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ= github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA= @@ -1807,8 +1802,6 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20170207211851-4464e7848382/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -2011,8 +2004,6 @@ golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2278,12 +2269,8 @@ google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2I google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac h1:ZL/Teoy/ZGnzyrqK/Optxxp2pmVh+fmJ97slxSRyzUg= google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw= google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI= google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= @@ -2303,8 +2290,6 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/x/confidentialtransfers/types/cryptography_test.go b/x/confidentialtransfers/types/cryptography_test.go index 9d34db6446..8b8a037731 100644 --- a/x/confidentialtransfers/types/cryptography_test.go +++ b/x/confidentialtransfers/types/cryptography_test.go @@ -20,8 +20,7 @@ func TestFromCiphertext(t *testing.T) { } // Convert to our Ciphertext type - c := &Ciphertext{} - cProto := c.ToProto(&ciphertext) + cProto := NewCiphertextProto(&ciphertext) assert.NoError(t, cProto.Validate()) diff --git a/x/confidentialtransfers/types/zk_test.go b/x/confidentialtransfers/types/zk_test.go index 63d25a3a06..1e02685982 100644 --- a/x/confidentialtransfers/types/zk_test.go +++ b/x/confidentialtransfers/types/zk_test.go @@ -312,7 +312,7 @@ func TestInitializeAccountMsgProofs_FromProto(t *testing.T) { Z: curves.ED25519().Scalar.Random(crand.Reader).Bytes(), }, }, - wantErr: true, + wantErr: false, }, { name: "missing PubkeyValidityProof", From 408a72ab1628a354bf3592974ed15850bf1bc530 Mon Sep 17 00:00:00 2001 From: mj Date: Mon, 4 Nov 2024 10:31:18 -0500 Subject: [PATCH 4/8] revert evm/params to old state --- x/evm/types/params.pb.go | 334 --------------------------------------- 1 file changed, 334 deletions(-) diff --git a/x/evm/types/params.pb.go b/x/evm/types/params.pb.go index 8a74acddbc..aa3dfb97c4 100644 --- a/x/evm/types/params.pb.go +++ b/x/evm/types/params.pb.go @@ -104,76 +104,8 @@ func (m *Params) GetTargetGasUsedPerBlock() uint64 { return 0 } -type ParamsPreV580 struct { - // string base_denom = 1 [ - // - // (gogoproto.moretags) = "yaml:\"base_denom\"", - // (gogoproto.jsontag) = "base_denom" - // - // ]; - PriorityNormalizer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=priority_normalizer,json=priorityNormalizer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"priority_normalizer" yaml:"priority_normalizer"` - BaseFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_fee_per_gas" yaml:"base_fee_per_gas"` - MinimumFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=minimum_fee_per_gas,json=minimumFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_fee_per_gas" yaml:"minimum_fee_per_gas"` - // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; - // - // string chain_id = 6 [ - // (gogoproto.moretags) = "yaml:\"chain_id\"", - // (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - // (gogoproto.nullable) = false, - // (gogoproto.jsontag) = "chain_id" - // - // ]; - // repeated string whitelisted_codehashes_bank_send = 7 [ - // - // (gogoproto.moretags) = "yaml:\"whitelisted_codehashes_bank_send\"", - // (gogoproto.jsontag) = "whitelisted_codehashes_bank_send" - // - // ]; - WhitelistedCwCodeHashesForDelegateCall [][]byte `protobuf:"bytes,8,rep,name=whitelisted_cw_code_hashes_for_delegate_call,json=whitelistedCwCodeHashesForDelegateCall,proto3" json:"whitelisted_cw_code_hashes_for_delegate_call" yaml:"whitelisted_cw_code_hashes_for_delegate_call"` -} - -func (m *ParamsPreV580) Reset() { *m = ParamsPreV580{} } -func (*ParamsPreV580) ProtoMessage() {} -func (*ParamsPreV580) Descriptor() ([]byte, []int) { - return fileDescriptor_9272f3679901ea94, []int{1} -} -func (m *ParamsPreV580) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ParamsPreV580) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ParamsPreV580.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ParamsPreV580) XXX_Merge(src proto.Message) { - xxx_messageInfo_ParamsPreV580.Merge(m, src) -} -func (m *ParamsPreV580) XXX_Size() int { - return m.Size() -} -func (m *ParamsPreV580) XXX_DiscardUnknown() { - xxx_messageInfo_ParamsPreV580.DiscardUnknown(m) -} - -var xxx_messageInfo_ParamsPreV580 proto.InternalMessageInfo - -func (m *ParamsPreV580) GetWhitelistedCwCodeHashesForDelegateCall() [][]byte { - if m != nil { - return m.WhitelistedCwCodeHashesForDelegateCall - } - return nil -} - func init() { proto.RegisterType((*Params)(nil), "seiprotocol.seichain.evm.Params") - proto.RegisterType((*ParamsPreV580)(nil), "seiprotocol.seichain.evm.ParamsPreV580") } func init() { proto.RegisterFile("evm/params.proto", fileDescriptor_9272f3679901ea94) } @@ -314,68 +246,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ParamsPreV580) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ParamsPreV580) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ParamsPreV580) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { - for iNdEx := len(m.WhitelistedCwCodeHashesForDelegateCall) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) - copy(dAtA[i:], m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]))) - i-- - dAtA[i] = 0x42 - } - } - { - size := m.MinimumFeePerGas.Size() - i -= size - if _, err := m.MinimumFeePerGas.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.BaseFeePerGas.Size() - i -= size - if _, err := m.BaseFeePerGas.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.PriorityNormalizer.Size() - i -= size - if _, err := m.PriorityNormalizer.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - return len(dAtA) - i, nil -} - func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -418,27 +288,6 @@ func (m *Params) Size() (n int) { return n } -func (m *ParamsPreV580) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.PriorityNormalizer.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.BaseFeePerGas.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.MinimumFeePerGas.Size() - n += 1 + l + sovParams(uint64(l)) - if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { - for _, b := range m.WhitelistedCwCodeHashesForDelegateCall { - l = len(b) - n += 1 + l + sovParams(uint64(l)) - } - } - return n -} - func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -735,190 +584,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } -func (m *ParamsPreV580) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ParamsPreV580: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ParamsPreV580: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PriorityNormalizer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PriorityNormalizer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BaseFeePerGas", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.BaseFeePerGas.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinimumFeePerGas", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinimumFeePerGas.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedCwCodeHashesForDelegateCall", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.WhitelistedCwCodeHashesForDelegateCall = append(m.WhitelistedCwCodeHashesForDelegateCall, make([]byte, postIndex-iNdEx)) - copy(m.WhitelistedCwCodeHashesForDelegateCall[len(m.WhitelistedCwCodeHashesForDelegateCall)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 92a156d5760365e235cbb9f11823f2b6cc70dbd7 Mon Sep 17 00:00:00 2001 From: mj Date: Mon, 4 Nov 2024 17:14:27 -0500 Subject: [PATCH 5/8] withdraw with tests --- go.mod | 2 + go.sum | 3 + proto/confidentialtransfers/tx.proto | 21 +- proto/confidentialtransfers/zk.proto | 5 + x/confidentialtransfers/types/codec.go | 4 + x/confidentialtransfers/types/msgs.go | 75 +++ x/confidentialtransfers/types/msgs_test.go | 192 ++++++ x/confidentialtransfers/types/tx.pb.go | 647 ++++++++++++++++++--- x/confidentialtransfers/types/withdraw.go | 26 + x/confidentialtransfers/types/zk.go | 41 ++ x/confidentialtransfers/types/zk.pb.go | 339 +++++++++-- x/confidentialtransfers/types/zk_test.go | 125 ++++ 12 files changed, 1351 insertions(+), 129 deletions(-) create mode 100644 x/confidentialtransfers/types/withdraw.go diff --git a/go.mod b/go.mod index b5c5151276..f5f35133ec 100644 --- a/go.mod +++ b/go.mod @@ -128,6 +128,7 @@ require ( github.com/fzipp/gocyclo v0.5.1 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.3 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -175,6 +176,7 @@ require ( github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect diff --git a/go.sum b/go.sum index 98d3af535d..e790fe32f1 100644 --- a/go.sum +++ b/go.sum @@ -460,6 +460,7 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2Gihuqh github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -768,6 +769,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= diff --git a/proto/confidentialtransfers/tx.proto b/proto/confidentialtransfers/tx.proto index b9cf8dc88b..5405677340 100644 --- a/proto/confidentialtransfers/tx.proto +++ b/proto/confidentialtransfers/tx.proto @@ -62,10 +62,29 @@ message MsgInitializeAccountResponse {} // MsgDeposit represents a message for depositing tokens into a confidential account message MsgDeposit { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; string denom = 2 [(gogoproto.moretags) = "yaml:\"denom\""]; uint64 amount = 3 [(gogoproto.moretags) = "yaml:\"amount\""]; } // MsgDepositResponse defines the Msg/Send response type. -message MsgDepositResponse {} \ No newline at end of file +message MsgDepositResponse {} + +// MsgWithdraw represents a message to withdraw from a confidential module account. +message MsgWithdraw { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string denom = 2 [(gogoproto.moretags) = "yaml:\"denom\""]; + uint64 amount = 3 [(gogoproto.moretags) = "yaml:\"amount\""]; + string decryptable_balance = 4 [(gogoproto.moretags) = "yaml:\"decryptable_balance\""]; + Ciphertext remaining_balance_commitment = 5 [(gogoproto.moretags) = "yaml:\"remaining_balance_commitment\""]; + WithdrawMsgProofs proofs = 6 [(gogoproto.moretags) = "yaml:\"proofs\""]; +} + +// MsgWithdrawResponse defines the Msg/Send response type. +message MsgWithdrawResponse {} \ No newline at end of file diff --git a/proto/confidentialtransfers/zk.proto b/proto/confidentialtransfers/zk.proto index be02d57535..d7f06c3f13 100644 --- a/proto/confidentialtransfers/zk.proto +++ b/proto/confidentialtransfers/zk.proto @@ -20,6 +20,11 @@ message InitializeAccountMsgProofs { PubkeyValidityProof pubkey_validity_proof = 1; } +message WithdrawMsgProofs { + RangeProof remaining_balance_range_proof = 1; + CiphertextCommitmentEqualityProof remaining_balance_equality_proof = 2; +} + message PubkeyValidityProof { bytes y = 1; bytes z = 2; diff --git a/x/confidentialtransfers/types/codec.go b/x/confidentialtransfers/types/codec.go index a88d5d071f..e8d81bfc60 100644 --- a/x/confidentialtransfers/types/codec.go +++ b/x/confidentialtransfers/types/codec.go @@ -11,6 +11,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgTransfer{}, "confidentialtransfers/MsgTransfer", nil) cdc.RegisterConcrete(&MsgInitializeAccount{}, "confidentialtransfers/MsgInitializeAccount", nil) cdc.RegisterConcrete(&MsgDeposit{}, "confidentialtransfers/MsgDeposit", nil) + cdc.RegisterConcrete(&MsgWithdraw{}, "confidentialtransfers/MsgWithdraw", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -23,6 +24,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgDeposit{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgWithdraw{}, + ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/confidentialtransfers/types/msgs.go b/x/confidentialtransfers/types/msgs.go index bdd3e03502..fba128dfb7 100644 --- a/x/confidentialtransfers/types/msgs.go +++ b/x/confidentialtransfers/types/msgs.go @@ -11,11 +11,13 @@ const ( TypeMsgTransfer = "transfer" TypeMsgInitializeAccount = "initialize_account" TypeMsgDeposit = "deposit" + TypeMsgWithdraw = "withdraw" ) var _ sdk.Msg = &MsgTransfer{} var _ sdk.Msg = &MsgInitializeAccount{} var _ sdk.Msg = &MsgDeposit{} +var _ sdk.Msg = &MsgWithdraw{} // Route Implements Msg. func (m *MsgTransfer) Route() string { return RouterKey } @@ -244,3 +246,76 @@ func (m *MsgDeposit) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.FromAddress) return []sdk.AccAddress{sender} } + +// Route Implements Msg. +func (m *MsgWithdraw) Route() string { return RouterKey } + +// Type Implements Msg. +func (m *MsgWithdraw) Type() string { return TypeMsgWithdraw } + +func (m *MsgWithdraw) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.FromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + err = sdk.ValidateDenom(m.Denom) + if err != nil { + return err + } + + if m.Amount <= 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Positive amount is required") + } + + if m.RemainingBalanceCommitment == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "RemainingBalanceCommitment is required") + } + + if m.DecryptableBalance == "" { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "DecryptableBalance is required") + } + + if m.Proofs == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Proofs is required") + } + + err = m.Proofs.Validate() + if err != nil { + return err + } + + return nil +} + +func (m *MsgWithdraw) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m)) +} + +func (m *MsgWithdraw) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.FromAddress) + return []sdk.AccAddress{sender} +} + +func (m *MsgWithdraw) FromProto() (*Withdraw, error) { + err := m.ValidateBasic() + + remainingBalanceCommitment, err := m.RemainingBalanceCommitment.FromProto() + if err != nil { + return nil, err + } + + proofs, err := m.Proofs.FromProto() + if err != nil { + return nil, err + } + + return &Withdraw{ + FromAddress: m.FromAddress, + Denom: m.Denom, + Amount: m.Amount, + RemainingBalanceCommitment: remainingBalanceCommitment, + DecryptableBalance: m.DecryptableBalance, + Proofs: proofs, + }, nil +} diff --git a/x/confidentialtransfers/types/msgs_test.go b/x/confidentialtransfers/types/msgs_test.go index 291d84e1cb..222b461399 100644 --- a/x/confidentialtransfers/types/msgs_test.go +++ b/x/confidentialtransfers/types/msgs_test.go @@ -521,3 +521,195 @@ func TestMsgInitializeAccount_ValidateBasic(t *testing.T) { }) } } + +func TestMsgWithdraw_FromProto(t *testing.T) { + testDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + sourcePrivateKey, _ := encryption.GenerateKey() + eg := elgamal.NewTwistedElgamal() + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, testDenom) + aesPK, err := encryption.GetAESKey(*sourcePrivateKey, testDenom) + require.NoError(t, err) + + currentBalance := uint64(500000000) + currentBalanceCt, _, _ := eg.Encrypt(sourceKeypair.PublicKey, currentBalance) + withdrawAmount := uint64(10000) + withdrawAmountCt, _ := eg.SubScalar(currentBalanceCt, withdrawAmount) + newBalance := currentBalance - withdrawAmount + newBalanceScalar := curves.ED25519().Scalar.New(int(newBalance)) + decryptableBalance, err := encryption.EncryptAESGCM(newBalance, aesPK) + newBalanceCommitment, randomness, err := eg.Encrypt(sourceKeypair.PublicKey, newBalance) + require.NoError(t, err) + + // Generate the proofs + rangeProof, _ := zkproofs.NewRangeProof(64, int(newBalance), randomness) + ciphertextCommitmentEqualityProof, _ := zkproofs.NewCiphertextCommitmentEqualityProof( + sourceKeypair, + withdrawAmountCt, + &randomness, + &newBalanceScalar) + + proofs := &WithdrawProofs{ + rangeProof, + ciphertextCommitmentEqualityProof, + } + address1 := sdk.AccAddress("address1") + + newBalanceProto := NewCiphertextProto(newBalanceCommitment) + + withdrawMsgProof := WithdrawMsgProofs{} + proofsProto := withdrawMsgProof.NewWithdrawMsgProofs(proofs) + m := &MsgWithdraw{ + FromAddress: address1.String(), + Denom: testDenom, + Amount: withdrawAmount, + RemainingBalanceCommitment: newBalanceProto, + DecryptableBalance: decryptableBalance, + Proofs: proofsProto, + } + + assert.NoError(t, m.ValidateBasic()) + + marshalled, err := m.Marshal() + require.NoError(t, err) + + // Reset the message + m = &MsgWithdraw{} + err = m.Unmarshal(marshalled) + require.NoError(t, err) + + assert.NoError(t, m.ValidateBasic()) + + result, err := m.FromProto() + + assert.NoError(t, err) + assert.Equal(t, m.FromAddress, result.FromAddress) + assert.Equal(t, m.Denom, result.Denom) + assert.Equal(t, m.Amount, result.Amount) + assert.Equal(t, m.DecryptableBalance, result.DecryptableBalance) + assert.True(t, newBalanceCommitment.C.Equal(result.RemainingBalanceCommitment.C)) + assert.True(t, newBalanceCommitment.D.Equal(result.RemainingBalanceCommitment.D)) + + decryptedRemainingBalance, err := encryption.DecryptAESGCM(result.DecryptableBalance, aesPK) + assert.NoError(t, err) + assert.Equal(t, newBalance, decryptedRemainingBalance) + + decryptedCommitment, err := eg.DecryptLargeNumber(sourceKeypair.PrivateKey, result.RemainingBalanceCommitment, 32) + assert.NoError(t, err) + assert.Equal(t, newBalance, decryptedCommitment) + + // Make sure the proofs are valid + verified, err := zkproofs.VerifyRangeProof(result.Proofs.RemainingBalanceRangeProof, result.RemainingBalanceCommitment, 64) + assert.NoError(t, err) + assert.True(t, verified) + + assert.True(t, zkproofs.VerifyCiphertextCommitmentEquality( + result.Proofs.RemainingBalanceEqualityProof, + &sourceKeypair.PublicKey, + withdrawAmountCt, + &result.RemainingBalanceCommitment.C)) +} + +func TestMsgWithdraw_ValidateBasic(t *testing.T) { + validAddress := sdk.AccAddress("address1").String() + invalidAddress := "invalid_address" + validDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + + tests := []struct { + name string + msg MsgWithdraw + wantErr bool + errMsg string + }{ + { + name: "invalid from address", + msg: MsgWithdraw{ + FromAddress: invalidAddress, + Denom: validDenom, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidAddress.Error(), + }, + { + name: "invalid denom", + msg: MsgWithdraw{ + FromAddress: validAddress, + Denom: "", + }, + wantErr: true, + errMsg: "invalid denom", + }, + { + name: "missing remaining balance commitment", + msg: MsgWithdraw{ + FromAddress: validAddress, + Denom: validDenom, + RemainingBalanceCommitment: nil, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + { + name: "missing amount", + msg: MsgWithdraw{ + FromAddress: validAddress, + Denom: validDenom, + RemainingBalanceCommitment: &Ciphertext{}, + Amount: 0, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + { + name: "missing decryptable balance", + msg: MsgWithdraw{ + FromAddress: validAddress, + Denom: validDenom, + RemainingBalanceCommitment: &Ciphertext{}, + Amount: 100, + DecryptableBalance: "", + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + { + name: "missing proofs", + msg: MsgWithdraw{ + FromAddress: validAddress, + Denom: validDenom, + RemainingBalanceCommitment: &Ciphertext{}, + Amount: 100, + DecryptableBalance: "notnil", + Proofs: nil, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + { + name: "happy path", + msg: MsgWithdraw{ + FromAddress: validAddress, + Denom: validDenom, + Amount: 100, + RemainingBalanceCommitment: &Ciphertext{}, + DecryptableBalance: "notnil", + Proofs: &WithdrawMsgProofs{ + &RangeProof{}, + &CiphertextCommitmentEqualityProof{}, + }, + }, + wantErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/confidentialtransfers/types/tx.pb.go b/x/confidentialtransfers/types/tx.pb.go index 874e171be6..74d33aed7a 100644 --- a/x/confidentialtransfers/types/tx.pb.go +++ b/x/confidentialtransfers/types/tx.pb.go @@ -324,27 +324,6 @@ func (m *MsgDeposit) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDeposit proto.InternalMessageInfo -func (m *MsgDeposit) GetFromAddress() string { - if m != nil { - return m.FromAddress - } - return "" -} - -func (m *MsgDeposit) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *MsgDeposit) GetAmount() uint64 { - if m != nil { - return m.Amount - } - return 0 -} - // MsgDepositResponse defines the Msg/Send response type. type MsgDepositResponse struct { } @@ -382,6 +361,86 @@ func (m *MsgDepositResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDepositResponse proto.InternalMessageInfo +// MsgWithdraw represents a message to withdraw from a confidential module account. +type MsgWithdraw struct { + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty" yaml:"amount"` + DecryptableBalance string `protobuf:"bytes,4,opt,name=decryptable_balance,json=decryptableBalance,proto3" json:"decryptable_balance,omitempty" yaml:"decryptable_balance"` + RemainingBalanceCommitment *Ciphertext `protobuf:"bytes,5,opt,name=remaining_balance_commitment,json=remainingBalanceCommitment,proto3" json:"remaining_balance_commitment,omitempty" yaml:"remaining_balance_commitment"` + Proofs *WithdrawMsgProofs `protobuf:"bytes,6,opt,name=proofs,proto3" json:"proofs,omitempty" yaml:"proofs"` +} + +func (m *MsgWithdraw) Reset() { *m = MsgWithdraw{} } +func (m *MsgWithdraw) String() string { return proto.CompactTextString(m) } +func (*MsgWithdraw) ProtoMessage() {} +func (*MsgWithdraw) Descriptor() ([]byte, []int) { + return fileDescriptor_34e86c2ca2c678f9, []int{7} +} +func (m *MsgWithdraw) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdraw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdraw.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgWithdraw) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdraw.Merge(m, src) +} +func (m *MsgWithdraw) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdraw) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdraw.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdraw proto.InternalMessageInfo + +// MsgWithdrawResponse defines the Msg/Send response type. +type MsgWithdrawResponse struct { +} + +func (m *MsgWithdrawResponse) Reset() { *m = MsgWithdrawResponse{} } +func (m *MsgWithdrawResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawResponse) ProtoMessage() {} +func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_34e86c2ca2c678f9, []int{8} +} +func (m *MsgWithdrawResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgWithdrawResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawResponse.Merge(m, src) +} +func (m *MsgWithdrawResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgTransfer)(nil), "seiprotocol.seichain.confidentialtransfers.MsgTransfer") proto.RegisterType((*MsgTransferResponse)(nil), "seiprotocol.seichain.confidentialtransfers.MsgTransferResponse") @@ -390,69 +449,75 @@ func init() { proto.RegisterType((*MsgInitializeAccountResponse)(nil), "seiprotocol.seichain.confidentialtransfers.MsgInitializeAccountResponse") proto.RegisterType((*MsgDeposit)(nil), "seiprotocol.seichain.confidentialtransfers.MsgDeposit") proto.RegisterType((*MsgDepositResponse)(nil), "seiprotocol.seichain.confidentialtransfers.MsgDepositResponse") + proto.RegisterType((*MsgWithdraw)(nil), "seiprotocol.seichain.confidentialtransfers.MsgWithdraw") + proto.RegisterType((*MsgWithdrawResponse)(nil), "seiprotocol.seichain.confidentialtransfers.MsgWithdrawResponse") } func init() { proto.RegisterFile("confidentialtransfers/tx.proto", fileDescriptor_34e86c2ca2c678f9) } var fileDescriptor_34e86c2ca2c678f9 = []byte{ - // 902 bytes of a gzipped FileDescriptorProto - 0x1f, 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0xb0, 0x83, 0x1d, - 0xb3, 0xd7, 0xd7, 0x6c, 0xcd, 0xd1, 0x91, 0x54, 0xdc, 0x88, 0x58, 0x0e, 0x03, 0xa5, 0x16, 0x5f, - 0x22, 0x96, 0x15, 0x5a, 0xdf, 0x46, 0x31, 0x38, 0x54, 0xef, 0x27, 0x84, 0x6d, 0x3e, 0x25, 0x7e, - 0x0e, 0xaa, 0x19, 0x3b, 0xa5, 0x12, 0xbb, 0x93, 0xd7, 0xc1, 0x89, 0xa9, 0xd9, 0x18, 0xd0, 0x02, - 0x05, 0xd7, 0x23, 0x64, 0x40, 0x25, 0xc0, 0x5c, 0xf9, 0x60, 0x15, 0x57, 0xe2, 0x74, 0xec, 0x52, - 0xf3, 0x0b, 0x06, 0xd2, 0xde, 0x0f, 0x03, 0xe5, 0x25, 0x2e, 0x81, 0xc3, 0x42, 0x35, 0xc2, 0x17, - 0x0d, 0x50, 0xd4, 0x46, 0x06, 0xf6, 0x89, 0x47, 0xa5, 0xf2, 0xd1, 0x56, 0xbd, 0x7c, 0xfc, 0x68, - 0x15, 0xae, 0x16, 0xb7, 0x6d, 0x57, 0xc3, 0x40, 0xb9, 0xc7, 0x19, 0x62, 0x38, 0xa8, 0x26, 0xc8, - 0x27, 0xc5, 0x1f, 0xcf, 0x95, 0xdc, 0x3f, 0xe7, 0x4a, 0x0e, 0x1e, 0x82, 0x6a, 0xaa, 0x62, 0xa8, - 0x88, 0xba, 0xc4, 0xa1, 0x08, 0xfe, 0x52, 0x02, 0xbb, 0x11, 0x96, 0xf8, 0x3e, 0xb8, 0x17, 0x19, - 0xce, 0x15, 0x12, 0x31, 0x0c, 0x94, 0xbd, 0x88, 0x24, 0xae, 0x05, 0x7b, 0xd1, 0xd6, 0xb8, 0x20, - 0x9c, 0x0b, 0xe0, 0x21, 0x72, 0x58, 0x40, 0x91, 0xd1, 0x8b, 0x85, 0xa6, 0xf2, 0x20, 0xbf, 0xd1, - 0xdd, 0x78, 0x23, 0x0c, 0x94, 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a6, 0x6b, 0x50, 0x2d, 0xf1, 0xc1, - 0xa7, 0x68, 0xbc, 0xac, 0x1f, 0x6d, 0xaf, 0xdd, 0x8f, 0x4e, 0x93, 0x7e, 0xc4, 0xb3, 0xe6, 0xe3, - 0x55, 0xce, 0x6b, 0x21, 0x72, 0x37, 0x69, 0x4c, 0xa9, 0x96, 0x21, 0x83, 0x87, 0x59, 0xf1, 0x4f, - 0x7a, 0xc7, 0xaf, 0x02, 0x00, 0x5d, 0x6a, 0x7e, 0x88, 0x5c, 0x42, 0xf1, 0xdd, 0x1c, 0xcb, 0x9b, - 0xa0, 0xc0, 0xef, 0x13, 0x3b, 0x92, 0xed, 0xb4, 0x1f, 0x7c, 0x1e, 0xaa, 0xd1, 0x06, 0x78, 0x00, - 0xc4, 0xa9, 0xb8, 0x58, 0xf3, 0xf1, 0x4f, 0x02, 0xd8, 0xea, 0x52, 0x53, 0xfc, 0x41, 0x00, 0xc5, - 0xe4, 0xf9, 0xfc, 0xde, 0x2a, 0x51, 0x4d, 0x75, 0xd1, 0xda, 0x93, 0x35, 0x0d, 0x63, 0x39, 0xed, - 0xaf, 0xff, 0xbc, 0x90, 0x85, 0x17, 0x17, 0xb2, 0xf0, 0xf7, 0x85, 0x2c, 0xfc, 0x7c, 0x29, 0xe7, - 0x5e, 0x5c, 0xca, 0xb9, 0xbf, 0x2e, 0xe5, 0xdc, 0x37, 0x4f, 0x4c, 0xec, 0x5b, 0xa3, 0x7e, 0x43, - 0x27, 0xc3, 0x26, 0x45, 0xf8, 0x9d, 0x98, 0x85, 0x0d, 0x18, 0x4d, 0xf3, 0xac, 0xb9, 0xe4, 0x97, - 0x65, 0xec, 0x22, 0xda, 0x2f, 0x30, 0x8b, 0x47, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x92, 0x09, - 0x52, 0x62, 0xd8, 0x0c, 0x00, 0x00, + // 970 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0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9, 0x5a, 0xfa, 0xeb, 0x5c, 0x2d, 0x7d, 0xfd, 0xd0, 0xc6, + 0xcc, 0xe9, 0xf7, 0x9a, 0x26, 0xf1, 0x5a, 0x14, 0xe1, 0xb7, 0x52, 0x16, 0x3e, 0xe0, 0x34, 0xad, + 0x93, 0xd6, 0x05, 0xff, 0xb6, 0x83, 0x00, 0xd1, 0x5e, 0x99, 0x5b, 0xdc, 0xff, 0x2f, 0x00, 0x00, + 0xff, 0xff, 0x6f, 0xeb, 0x29, 0x1a, 0x01, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -950,6 +1015,102 @@ func (m *MsgDepositResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgWithdraw) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgWithdraw) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdraw) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Proofs != nil { + { + size, err := m.Proofs.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.RemainingBalanceCommitment != nil { + { + size, err := m.RemainingBalanceCommitment.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.DecryptableBalance) > 0 { + i -= len(m.DecryptableBalance) + copy(dAtA[i:], m.DecryptableBalance) + i = encodeVarintTx(dAtA, i, uint64(len(m.DecryptableBalance))) + i-- + dAtA[i] = 0x22 + } + if m.Amount != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x18 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgWithdrawResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1129,6 +1290,47 @@ func (m *MsgDepositResponse) Size() (n int) { return n } +func (m *MsgWithdraw) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Amount != 0 { + n += 1 + sovTx(uint64(m.Amount)) + } + l = len(m.DecryptableBalance) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.RemainingBalanceCommitment != nil { + l = m.RemainingBalanceCommitment.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.Proofs != nil { + l = m.Proofs.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgWithdrawResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2360,6 +2562,293 @@ func (m *MsgDepositResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgWithdraw) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgWithdraw: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdraw: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FromAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecryptableBalance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DecryptableBalance = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RemainingBalanceCommitment", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RemainingBalanceCommitment == nil { + m.RemainingBalanceCommitment = &Ciphertext{} + } + if err := m.RemainingBalanceCommitment.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proofs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Proofs == nil { + m.Proofs = &WithdrawMsgProofs{} + } + if err := m.Proofs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgWithdrawResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgWithdrawResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/confidentialtransfers/types/withdraw.go b/x/confidentialtransfers/types/withdraw.go new file mode 100644 index 0000000000..81f882ce34 --- /dev/null +++ b/x/confidentialtransfers/types/withdraw.go @@ -0,0 +1,26 @@ +package types + +import ( + "github.com/sei-protocol/sei-cryptography/pkg/encryption/elgamal" + "github.com/sei-protocol/sei-cryptography/pkg/zkproofs" +) + +type Withdraw struct { + FromAddress string `json:"from_address"` + Denom string `json:"denom"` + Amount uint64 `json:"amount"` + DecryptableBalance string `json:"decrypted_balance"` + + // The Encrypted remaining balance, but re-encrypted from its plaintext form. + RemainingBalanceCommitment *elgamal.Ciphertext `json:"remaining_balance_commitment"` + + Proofs *WithdrawProofs `json:"proofs"` +} + +type WithdrawProofs struct { + // Proof that the remaining balance sent as a Commitment is greater or equal to 0 + RemainingBalanceRangeProof *zkproofs.RangeProof `json:"remaining_balance_range_proof"` + + // Equality proof that AvaialbleBalance - Enc(Amount) is equal to the RemainingBalance sent. + RemainingBalanceEqualityProof *zkproofs.CiphertextCommitmentEqualityProof `json:"remaining_balance_equality_proof"` +} diff --git a/x/confidentialtransfers/types/zk.go b/x/confidentialtransfers/types/zk.go index c6398a7d24..5a9db3b391 100644 --- a/x/confidentialtransfers/types/zk.go +++ b/x/confidentialtransfers/types/zk.go @@ -139,6 +139,47 @@ func NewInitializeAccountMsgProofs(proofs *InitializeAccountProofs) *InitializeA } } +func (w *WithdrawMsgProofs) FromProto() (*WithdrawProofs, error) { + err := w.Validate() + if err != nil { + return nil, err + } + + remainingBalanceRangeProof, err := w.RemainingBalanceRangeProof.FromProto() + if err != nil { + return nil, err + } + + remainingBalanceEqualityProof, err := w.RemainingBalanceEqualityProof.FromProto() + if err != nil { + return nil, err + } + + return &WithdrawProofs{ + RemainingBalanceRangeProof: remainingBalanceRangeProof, + RemainingBalanceEqualityProof: remainingBalanceEqualityProof, + }, nil +} + +func (w *WithdrawMsgProofs) Validate() error { + if w.RemainingBalanceRangeProof == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "remaining balance range proof is required") + } + + if w.RemainingBalanceEqualityProof == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "remaining balance equality proof is required") + } + + return nil +} + +func (w *WithdrawMsgProofs) NewWithdrawMsgProofs(proofs *WithdrawProofs) *WithdrawMsgProofs { + return &WithdrawMsgProofs{ + RemainingBalanceRangeProof: w.RemainingBalanceRangeProof.ToProto(proofs.RemainingBalanceRangeProof), + RemainingBalanceEqualityProof: w.RemainingBalanceEqualityProof.ToProto(proofs.RemainingBalanceEqualityProof), + } +} + func (c *InitializeAccountMsgProofs) FromProto() (*InitializeAccountProofs, error) { err := c.Validate() if err != nil { diff --git a/x/confidentialtransfers/types/zk.pb.go b/x/confidentialtransfers/types/zk.pb.go index 1ed654a8d8..bb1223ee33 100644 --- a/x/confidentialtransfers/types/zk.pb.go +++ b/x/confidentialtransfers/types/zk.pb.go @@ -174,6 +174,58 @@ func (m *InitializeAccountMsgProofs) GetPubkeyValidityProof() *PubkeyValidityPro return nil } +type WithdrawMsgProofs struct { + RemainingBalanceRangeProof *RangeProof `protobuf:"bytes,1,opt,name=remaining_balance_range_proof,json=remainingBalanceRangeProof,proto3" json:"remaining_balance_range_proof,omitempty"` + RemainingBalanceEqualityProof *CiphertextCommitmentEqualityProof `protobuf:"bytes,2,opt,name=remaining_balance_equality_proof,json=remainingBalanceEqualityProof,proto3" json:"remaining_balance_equality_proof,omitempty"` +} + +func (m *WithdrawMsgProofs) Reset() { *m = WithdrawMsgProofs{} } +func (m *WithdrawMsgProofs) String() string { return proto.CompactTextString(m) } +func (*WithdrawMsgProofs) ProtoMessage() {} +func (*WithdrawMsgProofs) Descriptor() ([]byte, []int) { + return fileDescriptor_71d8640cbb42ddec, []int{2} +} +func (m *WithdrawMsgProofs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WithdrawMsgProofs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WithdrawMsgProofs.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *WithdrawMsgProofs) XXX_Merge(src proto.Message) { + xxx_messageInfo_WithdrawMsgProofs.Merge(m, src) +} +func (m *WithdrawMsgProofs) XXX_Size() int { + return m.Size() +} +func (m *WithdrawMsgProofs) XXX_DiscardUnknown() { + xxx_messageInfo_WithdrawMsgProofs.DiscardUnknown(m) +} + +var xxx_messageInfo_WithdrawMsgProofs proto.InternalMessageInfo + +func (m *WithdrawMsgProofs) GetRemainingBalanceRangeProof() *RangeProof { + if m != nil { + return m.RemainingBalanceRangeProof + } + return nil +} + +func (m *WithdrawMsgProofs) GetRemainingBalanceEqualityProof() *CiphertextCommitmentEqualityProof { + if m != nil { + return m.RemainingBalanceEqualityProof + } + return nil +} + type PubkeyValidityProof struct { Y []byte `protobuf:"bytes,1,opt,name=y,proto3" json:"y,omitempty"` Z []byte `protobuf:"bytes,2,opt,name=z,proto3" json:"z,omitempty"` @@ -183,7 +235,7 @@ func (m *PubkeyValidityProof) Reset() { *m = PubkeyValidityProof{} } func (m *PubkeyValidityProof) String() string { return proto.CompactTextString(m) } func (*PubkeyValidityProof) ProtoMessage() {} func (*PubkeyValidityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{2} + return fileDescriptor_71d8640cbb42ddec, []int{3} } func (m *PubkeyValidityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -241,7 +293,7 @@ func (m *CiphertextValidityProof) Reset() { *m = CiphertextValidityProof func (m *CiphertextValidityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextValidityProof) ProtoMessage() {} func (*CiphertextValidityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{3} + return fileDescriptor_71d8640cbb42ddec, []int{4} } func (m *CiphertextValidityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -308,7 +360,7 @@ func (m *RangeProof) Reset() { *m = RangeProof{} } func (m *RangeProof) String() string { return proto.CompactTextString(m) } func (*RangeProof) ProtoMessage() {} func (*RangeProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{4} + return fileDescriptor_71d8640cbb42ddec, []int{5} } func (m *RangeProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -371,7 +423,7 @@ func (m *CiphertextCommitmentEqualityProof) Reset() { *m = CiphertextCom func (m *CiphertextCommitmentEqualityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextCommitmentEqualityProof) ProtoMessage() {} func (*CiphertextCommitmentEqualityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{5} + return fileDescriptor_71d8640cbb42ddec, []int{6} } func (m *CiphertextCommitmentEqualityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -456,7 +508,7 @@ func (m *CiphertextCiphertextEqualityProof) Reset() { *m = CiphertextCip func (m *CiphertextCiphertextEqualityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextCiphertextEqualityProof) ProtoMessage() {} func (*CiphertextCiphertextEqualityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{6} + return fileDescriptor_71d8640cbb42ddec, []int{7} } func (m *CiphertextCiphertextEqualityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -537,6 +589,7 @@ func (m *CiphertextCiphertextEqualityProof) GetZr() []byte { func init() { proto.RegisterType((*TransferMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.TransferMsgProofs") proto.RegisterType((*InitializeAccountMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.InitializeAccountMsgProofs") + proto.RegisterType((*WithdrawMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.WithdrawMsgProofs") proto.RegisterType((*PubkeyValidityProof)(nil), "seiprotocol.seichain.confidentialtransfers.PubkeyValidityProof") proto.RegisterType((*CiphertextValidityProof)(nil), "seiprotocol.seichain.confidentialtransfers.CiphertextValidityProof") proto.RegisterType((*RangeProof)(nil), "seiprotocol.seichain.confidentialtransfers.RangeProof") @@ -547,50 +600,52 @@ func init() { func init() { proto.RegisterFile("confidentialtransfers/zk.proto", fileDescriptor_71d8640cbb42ddec) } var fileDescriptor_71d8640cbb42ddec = []byte{ - // 680 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x96, 0x5d, 0x6b, 0x13, 0x4d, - 0x14, 0xc7, 0x3b, 0xe9, 0xd3, 0xf6, 0xe9, 0x69, 0x10, 0xdc, 0x2a, 0x4a, 0xa1, 0x6b, 0xbb, 0x82, - 0x16, 0xc5, 0xa4, 0xbb, 0x05, 0x6f, 0x4b, 0x5b, 0x84, 0x0a, 0x16, 0xca, 0x22, 0x82, 0xde, 0x2c, - 0x9b, 0xcd, 0x34, 0x19, 0x9a, 0x9d, 0x59, 0x67, 0x26, 0x92, 0xdd, 0x5b, 0xbf, 0x80, 0x22, 0x28, - 0x08, 0x82, 0x7e, 0x1b, 0x2f, 0x7b, 0xe9, 0xa5, 0xb4, 0x1f, 0x44, 0xd9, 0xc9, 0xe4, 0x65, 0x27, - 0xb1, 0x69, 0x6b, 0xeb, 0xdd, 0xfe, 0xe7, 0xe5, 0xfc, 0x7f, 0x7b, 0xf6, 0x9c, 0x93, 0x80, 0x1d, - 0x31, 0x7a, 0x40, 0xea, 0x98, 0x4a, 0x12, 0xb6, 0x24, 0x0f, 0xa9, 0x38, 0xc0, 0x5c, 0x54, 0xb3, - 0xc3, 0x4a, 0xc2, 0x99, 0x64, 0xd6, 0x03, 0x81,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x7e, 0x07, 0x00, 0x00, 0xff, 0xff, - 0xe1, 0xa1, 0xeb, 0x04, 0x19, 0x09, 0x00, 0x00, + // 706 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0xc1, 0x6b, 0xd4, 0x4e, + 0x14, 0xc7, 0x3b, 0xe9, 0xaf, 0xed, 0xaf, 0xaf, 0x8b, 0xd0, 0x54, 0x51, 0x0a, 0x8d, 0x6d, 0x04, + 0x2d, 0x8a, 0xbb, 0x4d, 0x0a, 0x5e, 0x4b, 0x5b, 0x84, 0x0a, 0x16, 0x4a, 0x10, 0x45, 0x2f, 0x21, + 0x9b, 0x9d, 0xee, 0x0e, 0xdd, 0xcc, 0xc4, 0x99, 0x59, 0xdd, 0xe4, 0xea, 0x3f, 0xa0, 0x08, 0x0a, + 0x82, 0xa0, 0x27, 0xff, 0x15, 0x8f, 0x3d, 0x7a, 0x94, 0xee, 0x1f, 0xa2, 0x64, 0x36, 0xbb, 0xd9, + 0x64, 0xd7, 0x6e, 0x5b, 0xdb, 0x7a, 0xdb, 0xf7, 0x66, 0xe6, 0x7d, 0x3f, 0xf9, 0xe6, 0xcd, 0xcb, + 0x82, 0xe1, 0x33, 0xba, 0x4f, 0x6a, 0x98, 0x4a, 0xe2, 0x35, 0x25, 0xf7, 0xa8, 0xd8, 0xc7, 0x5c, + 0x54, 0xe2, 0x83, 0x72, 0xc8, 0x99, 0x64, 0xfa, 0x5d, 0x81, 0x89, 0xfa, 0xe5, 0xb3, 0x66, 0x59, + 0x60, 0xe2, 0x37, 0x3c, 0x42, 0xcb, 0x23, 0x0f, 0x99, 0xbf, 0x00, 0xe6, 0x9f, 0xa4, 0xd1, 0xae, + 0xa8, 0xef, 0x71, 0xc6, 0xf6, 0x85, 0xfe, 0x15, 0xc1, 0x3d, 0x8e, 0x03, 0x8f, 0x50, 0x42, 0xeb, + 0x6e, 0xd5, 0x6b, 0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, 0x6e, + 0xa0, 0x1b, 0x00, 0xdc, 0xa3, 0x35, 0x16, 0x50, 0x2c, 0x44, 0x8a, 0x30, 0x90, 0xd1, 0x6f, 0xc2, + 0x5c, 0x2b, 0x0c, 0x31, 0x77, 0xab, 0xac, 0x45, 0x6b, 0xea, 0x0b, 0x37, 0xe9, 0x80, 0x4a, 0x6d, + 0x25, 0x19, 0xf3, 0x0d, 0x82, 0x95, 0xb1, 0xe6, 0xeb, 0x57, 0x40, 0x8b, 0xd6, 0x52, 0x65, 0x2d, + 0x5a, 0x53, 0xb1, 0x95, 0xca, 0x69, 0x91, 0xa5, 0x62, 0x5b, 0x55, 0x4f, 0x62, 0x3b, 0x89, 0x63, + 0x91, 0x3e, 0xb0, 0x16, 0x0b, 0x15, 0xb7, 0xd3, 0x27, 0xd4, 0xe2, 0xb6, 0x8a, 0xb9, 0x1a, 0xcc, + 0x49, 0xcc, 0xcd, 0xf7, 0x79, 0x8a, 0xd1, 0x17, 0xf8, 0x2c, 0x14, 0xd1, 0x7a, 0x8f, 0x22, 0x5a, + 0x4f, 0xa9, 0xa6, 0x0a, 0x54, 0xd3, 0x05, 0xaa, 0x99, 0x1e, 0xd5, 0xd6, 0xf3, 0xef, 0x47, 0x06, + 0x3a, 0x3c, 0x32, 0xd0, 0xcf, 0x23, 0x03, 0xbd, 0xed, 0x18, 0x13, 0x87, 0x1d, 0x63, 0xe2, 0x47, + 0xc7, 0x98, 0x78, 0xb1, 0x51, 0x27, 0xb2, 0xd1, 0xaa, 0x96, 0x7d, 0x16, 0x54, 0x04, 0x26, 0xf7, + 0x7b, 0x6d, 0xae, 0x02, 0xd5, 0xe7, 0x95, 0x76, 0x65, 0xf4, 0xbf, 0x43, 0x19, 0x85, 0x58, 0x54, + 0xa7, 0xd5, 0x89, 0xf5, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x7e, 0x16, 0x2c, 0x43, 0x0a, + 0x00, 0x00, } func (m *TransferMsgProofs) Marshal() (dAtA []byte, err error) { @@ -759,6 +814,53 @@ func (m *InitializeAccountMsgProofs) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *WithdrawMsgProofs) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *WithdrawMsgProofs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WithdrawMsgProofs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RemainingBalanceEqualityProof != nil { + { + size, err := m.RemainingBalanceEqualityProof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintZk(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.RemainingBalanceRangeProof != nil { + { + size, err := m.RemainingBalanceRangeProof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintZk(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *PubkeyValidityProof) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1095,6 +1197,23 @@ func (m *InitializeAccountMsgProofs) Size() (n int) { return n } +func (m *WithdrawMsgProofs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RemainingBalanceRangeProof != nil { + l = m.RemainingBalanceRangeProof.Size() + n += 1 + l + sovZk(uint64(l)) + } + if m.RemainingBalanceEqualityProof != nil { + l = m.RemainingBalanceEqualityProof.Size() + n += 1 + l + sovZk(uint64(l)) + } + return n +} + func (m *PubkeyValidityProof) Size() (n int) { if m == nil { return 0 @@ -1693,6 +1812,128 @@ func (m *InitializeAccountMsgProofs) Unmarshal(dAtA []byte) error { } return nil } +func (m *WithdrawMsgProofs) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: WithdrawMsgProofs: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WithdrawMsgProofs: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RemainingBalanceRangeProof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZk + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZk + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RemainingBalanceRangeProof == nil { + m.RemainingBalanceRangeProof = &RangeProof{} + } + if err := m.RemainingBalanceRangeProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RemainingBalanceEqualityProof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZk + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZk + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RemainingBalanceEqualityProof == nil { + m.RemainingBalanceEqualityProof = &CiphertextCommitmentEqualityProof{} + } + if err := m.RemainingBalanceEqualityProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipZk(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthZk + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *PubkeyValidityProof) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/confidentialtransfers/types/zk_test.go b/x/confidentialtransfers/types/zk_test.go index 1e02685982..5fe85b7d33 100644 --- a/x/confidentialtransfers/types/zk_test.go +++ b/x/confidentialtransfers/types/zk_test.go @@ -3,6 +3,9 @@ package types import ( crand "crypto/rand" "github.com/coinbase/kryptology/pkg/core/curves" + "github.com/sei-protocol/sei-cryptography/pkg/encryption" + "github.com/sei-protocol/sei-cryptography/pkg/encryption/elgamal" + "github.com/sei-protocol/sei-cryptography/pkg/zkproofs" "github.com/stretchr/testify/require" "testing" ) @@ -334,3 +337,125 @@ func TestInitializeAccountMsgProofs_FromProto(t *testing.T) { }) } } + +func TestWithdrawMsgProofs_FromProto(t *testing.T) { + testDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + sourcePrivateKey, _ := encryption.GenerateKey() + eg := elgamal.NewTwistedElgamal() + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, testDenom) + value := uint64(100) + scalarValue := curves.ED25519().Scalar.New(int(value)) + encrypted, randomness, _ := eg.Encrypt(sourceKeypair.PublicKey, value) + rangeProof, _ := zkproofs.NewRangeProof(64, int(value), randomness) + rp := RangeProof{} + rangeProofProto := rp.ToProto(rangeProof) + + ep := CiphertextCommitmentEqualityProof{} + equalityProof, _ := zkproofs.NewCiphertextCommitmentEqualityProof(sourceKeypair, encrypted, &randomness, &scalarValue) + equalityProofProto := ep.ToProto(equalityProof) + + tests := []struct { + name string + proofs WithdrawMsgProofs + wantErr bool + errMsg string + }{ + { + name: "valid proofs", + proofs: WithdrawMsgProofs{ + RemainingBalanceRangeProof: rangeProofProto, + RemainingBalanceEqualityProof: equalityProofProto, + }, + wantErr: false, + }, + { + name: "missing RangeProof", + proofs: WithdrawMsgProofs{ + RemainingBalanceEqualityProof: equalityProofProto, + }, + wantErr: true, + errMsg: "range proof is required", + }, + { + name: "missing CiphertextCommitmentEqualityProof", + proofs: WithdrawMsgProofs{ + RemainingBalanceRangeProof: rangeProofProto, + }, + wantErr: true, + errMsg: "remaining balance equality proof is required", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := tt.proofs.FromProto() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestWithdrawMsgProofs_Validate(t *testing.T) { + testDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + sourcePrivateKey, _ := encryption.GenerateKey() + eg := elgamal.NewTwistedElgamal() + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, testDenom) + value := uint64(100) + scalarValue := curves.ED25519().Scalar.New(int(value)) + encrypted, randomness, _ := eg.Encrypt(sourceKeypair.PublicKey, value) + rangeProof, _ := zkproofs.NewRangeProof(64, int(value), randomness) + rp := RangeProof{} + rangeProofProto := rp.ToProto(rangeProof) + + ep := CiphertextCommitmentEqualityProof{} + equalityProof, _ := zkproofs.NewCiphertextCommitmentEqualityProof(sourceKeypair, encrypted, &randomness, &scalarValue) + equalityProofProto := ep.ToProto(equalityProof) + + tests := []struct { + name string + proofs WithdrawMsgProofs + wantErr bool + errMsg string + }{ + { + name: "valid proofs", + proofs: WithdrawMsgProofs{ + RemainingBalanceRangeProof: rangeProofProto, + RemainingBalanceEqualityProof: equalityProofProto, + }, + wantErr: false, + }, + { + name: "missing RangeProof", + proofs: WithdrawMsgProofs{ + RemainingBalanceEqualityProof: equalityProofProto, + }, + wantErr: true, + errMsg: "range proof is required", + }, + { + name: "missing CiphertextCommitmentEqualityProof", + proofs: WithdrawMsgProofs{ + RemainingBalanceRangeProof: rangeProofProto, + }, + wantErr: true, + errMsg: "remaining balance equality proof is required", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.proofs.Validate() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} From ef556b362091605670713c888f61812cae660eb9 Mon Sep 17 00:00:00 2001 From: mj Date: Mon, 4 Nov 2024 21:17:30 -0500 Subject: [PATCH 6/8] small changes --- proto/confidentialtransfers/tx.proto | 9 +++++++++ x/confidentialtransfers/types/msgs.go | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/proto/confidentialtransfers/tx.proto b/proto/confidentialtransfers/tx.proto index 5405677340..00f2d72753 100644 --- a/proto/confidentialtransfers/tx.proto +++ b/proto/confidentialtransfers/tx.proto @@ -12,6 +12,15 @@ option go_package = "github.com/sei-protocol/sei-chain/x/confidentialtransfers/t service Msg { // Transfer defines a method for sending coins from one account to another account. rpc Transfer(MsgTransfer) returns (MsgTransferResponse); + + // InitializeAccount defines a method for creating a new confidential transfers account for some denom. + rpc InitializeAccount(MsgInitializeAccount) returns (MsgInitializeAccount); + + // Deposit defines a method for depositing funds into a confidential transfers account. + rpc Deposit(MsgDeposit) returns (MsgDeposit); + + // Withdraw defines a method for withdrawing funds from a confidential transfers account. + rpc Withdraw(MsgWithdraw) returns (MsgWithdraw); } // MsgTransfer represents a message to send coins from one account to another. diff --git a/x/confidentialtransfers/types/msgs.go b/x/confidentialtransfers/types/msgs.go index fba128dfb7..4d23c2a735 100644 --- a/x/confidentialtransfers/types/msgs.go +++ b/x/confidentialtransfers/types/msgs.go @@ -15,9 +15,6 @@ const ( ) var _ sdk.Msg = &MsgTransfer{} -var _ sdk.Msg = &MsgInitializeAccount{} -var _ sdk.Msg = &MsgDeposit{} -var _ sdk.Msg = &MsgWithdraw{} // Route Implements Msg. func (m *MsgTransfer) Route() string { return RouterKey } @@ -142,6 +139,8 @@ func (m *MsgTransfer) FromProto() (*Transfer, error) { }, nil } +var _ sdk.Msg = &MsgInitializeAccount{} + // Route Implements Msg. func (m *MsgInitializeAccount) Route() string { return RouterKey } @@ -214,6 +213,8 @@ func (m *MsgInitializeAccount) FromProto() (*InitializeAccount, error) { }, nil } +var _ sdk.Msg = &MsgDeposit{} + // Route Implements Msg. func (m *MsgDeposit) Route() string { return RouterKey } @@ -247,6 +248,8 @@ func (m *MsgDeposit) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } +var _ sdk.Msg = &MsgWithdraw{} + // Route Implements Msg. func (m *MsgWithdraw) Route() string { return RouterKey } From a749b878406613d3baf6ffd18226f2ef8817b1e2 Mon Sep 17 00:00:00 2001 From: mj Date: Mon, 4 Nov 2024 23:26:37 -0500 Subject: [PATCH 7/8] refactor and add tests --- proto/confidentialtransfers/tx.proto | 12 +- proto/confidentialtransfers/zk.proto | 12 +- x/confidentialtransfers/types/msgs.go | 24 +- x/confidentialtransfers/types/msgs_test.go | 212 +++++- x/confidentialtransfers/types/tx.pb.go | 210 +++--- x/confidentialtransfers/types/zk.go | 61 +- x/confidentialtransfers/types/zk.pb.go | 725 ++++++++++----------- x/confidentialtransfers/types/zk_test.go | 132 +++- 8 files changed, 830 insertions(+), 558 deletions(-) diff --git a/proto/confidentialtransfers/tx.proto b/proto/confidentialtransfers/tx.proto index c411a6e887..d38bc4d0f8 100644 --- a/proto/confidentialtransfers/tx.proto +++ b/proto/confidentialtransfers/tx.proto @@ -107,6 +107,9 @@ message MsgWithdrawResponse {} // Message to be used in apply pending balance instruction/transaction message MsgApplyPendingBalance { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + string address = 1; string denom = 2; string new_decryptable_available_balance = 3; @@ -116,9 +119,12 @@ message MsgApplyPendingBalanceResponse {} // Message to be used in close account instruction/transaction message MsgCloseAccount { - string address = 1; - string denom = 2; - CloseAccountProof proof = 3; + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string address = 1 [(gogoproto.moretags) = "yaml:\"address\""]; + string denom = 2 [(gogoproto.moretags) = "yaml:\"denom\""]; + CloseAccountMsgProofs proofs = 3 [(gogoproto.moretags) = "yaml:\"proofs\""]; } message MsgCloseAccountResponse {} diff --git a/proto/confidentialtransfers/zk.proto b/proto/confidentialtransfers/zk.proto index 5057b90f26..7e1497545f 100644 --- a/proto/confidentialtransfers/zk.proto +++ b/proto/confidentialtransfers/zk.proto @@ -25,6 +25,12 @@ message WithdrawMsgProofs { CiphertextCommitmentEqualityProof remaining_balance_equality_proof = 2; } +message CloseAccountMsgProofs { + ZeroBalanceProof zero_available_balance_proof = 1; + ZeroBalanceProof zero_pending_balance_lo_proof = 2; + ZeroBalanceProof zero_pending_balance_hi_proof = 3; +} + message PubkeyValidityProof { bytes y = 1; bytes z = 2; @@ -73,10 +79,4 @@ message ZeroBalanceProof { bytes y_p = 1; bytes y_d = 2; bytes z = 3; -} - -message CloseAccountProof { - ZeroBalanceProof zero_available_balance_proof = 1; - ZeroBalanceProof zero_pending_balance_lo_proof = 2; - ZeroBalanceProof zero_pending_balance_hi_proof = 3; } \ No newline at end of file diff --git a/x/confidentialtransfers/types/msgs.go b/x/confidentialtransfers/types/msgs.go index cb7de68c77..78b95640ce 100644 --- a/x/confidentialtransfers/types/msgs.go +++ b/x/confidentialtransfers/types/msgs.go @@ -224,12 +224,14 @@ func (m *MsgApplyPendingBalance) Route() string { return RouterKey } func (m *MsgApplyPendingBalance) Type() string { return TypeMsgApplyPendingBalance } func (m *MsgApplyPendingBalance) ValidateBasic() error { - if len(m.Address) == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Address is required") + _, err := sdk.AccAddressFromBech32(m.Address) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) } - if len(m.Denom) == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Denom is required") + err = sdk.ValidateDenom(m.Denom) + if err != nil { + return err } if len(m.NewDecryptableAvailableBalance) == 0 { @@ -256,19 +258,21 @@ func (m *MsgCloseAccount) Route() string { return RouterKey } func (m *MsgCloseAccount) Type() string { return TypeMsgCloseAccount } func (m *MsgCloseAccount) ValidateBasic() error { - if len(m.Address) == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Address is required") + _, err := sdk.AccAddressFromBech32(m.Address) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) } - if len(m.Denom) == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Denom is required") + err = sdk.ValidateDenom(m.Denom) + if err != nil { + return err } - if m.Proof == nil { + if m.Proofs == nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Proofs is required") } - err := m.Proof.Validate() + err = m.Proofs.Validate() if err != nil { return err diff --git a/x/confidentialtransfers/types/msgs_test.go b/x/confidentialtransfers/types/msgs_test.go index d66aac04bb..44d8fe2435 100644 --- a/x/confidentialtransfers/types/msgs_test.go +++ b/x/confidentialtransfers/types/msgs_test.go @@ -100,8 +100,7 @@ func TestMsgTransfer_FromProto(t *testing.T) { TransferAmountHiEqualityProof: transferAmountHiEqualityProof, } - transferProofs := &TransferMsgProofs{} - proofsProto := transferProofs.ToProto(proofs) + proofsProto := NewTransferMsgProofs(proofs) address1 := sdk.AccAddress("address1") address2 := sdk.AccAddress("address2") auditorAddress := sdk.AccAddress("auditor") @@ -128,7 +127,6 @@ func TestMsgTransfer_FromProto(t *testing.T) { &auditorCipherAmountHiR, &scalarAmountHi) - auditor := Auditor{} transferAuditor := &TransferAuditor{ Address: auditorAddress.String(), EncryptedTransferAmountLo: auditorCipherAmountLo, @@ -138,7 +136,7 @@ func TestMsgTransfer_FromProto(t *testing.T) { TransferAmountLoEqualityProof: auditorTransferAmountLoEqualityProof, TransferAmountHiEqualityProof: auditorTransferAmountHiEqualityProof, } - auditorProto := auditor.ToProto(transferAuditor) + auditorProto := NewAuditorProto(transferAuditor) m := &MsgTransfer{ FromAddress: address1.String(), @@ -441,10 +439,11 @@ func TestMsgInitializeAccount_FromProto(t *testing.T) { result, err := m.FromProto() assert.NoError(t, err) + assert.Equal(t, m.FromAddress, result.FromAddress) assert.Equal(t, m.Denom, result.Denom) assert.Equal(t, m.DecryptableBalance, result.DecryptableBalance) - assert.Equal(t, m.PublicKey, result.Pubkey) + assert.True(t, sourceKeypair.PublicKey.Equal(*result.Pubkey)) decryptedRemainingBalance, err := encryption.DecryptAESGCM(result.DecryptableBalance, aesPK) assert.NoError(t, err) @@ -716,7 +715,7 @@ func TestMsgWithdraw_ValidateBasic(t *testing.T) { func TestMsgCloseAccount_FromProto(t *testing.T) { address := sdk.AccAddress("address1") testDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" - privateKey, _ := elgamal.GenerateKey() + privateKey, _ := encryption.GenerateKey() eg := elgamal.NewTwistedElgamal() keypair, _ := eg.KeyGen(*privateKey, testDenom) availableBalanceCiphertext, _, _ := eg.Encrypt(keypair.PublicKey, 0) @@ -736,13 +735,12 @@ func TestMsgCloseAccount_FromProto(t *testing.T) { ZeroPendingBalanceHiProof: pendingBalanceProofHi, } - closeAccountProof := CloseAccountProof{} - proof := closeAccountProof.ToProto(closeAccountProofs) + proof := NewCloseAccountMsgProofs(closeAccountProofs) m := &MsgCloseAccount{ Address: address.String(), Denom: testDenom, - Proof: proof, + Proofs: proof, } marshalled, err := m.Marshal() @@ -754,7 +752,7 @@ func TestMsgCloseAccount_FromProto(t *testing.T) { assert.Equal(t, m.Address, result.Address) assert.Equal(t, m.Denom, result.Denom) - resultProof, err := result.Proof.FromProto() + resultProof, err := result.Proofs.FromProto() require.NoError(t, err) assert.NoError(t, result.ValidateBasic()) @@ -781,3 +779,197 @@ func TestMsgCloseAccount_FromProto(t *testing.T) { assert.True(t, zkproofs.VerifyZeroBalance( resultProof.ZeroPendingBalanceHiProof, &keypair.PublicKey, pendingBalanceHiCiphertext)) } + +func TestMsgCloseAccount_ValidateBasic(t *testing.T) { + validAddress := sdk.AccAddress("address1").String() + invalidAddress := "invalid_address" + validDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + + tests := []struct { + name string + msg MsgCloseAccount + wantErr bool + errMsg string + }{ + { + name: "invalid address", + msg: MsgCloseAccount{ + Address: invalidAddress, + Denom: validDenom, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidAddress.Error(), + }, + { + name: "invalid denom", + msg: MsgCloseAccount{ + Address: validAddress, + Denom: "", + }, + wantErr: true, + errMsg: "invalid denom", + }, + { + name: "missing proofs", + msg: MsgCloseAccount{ + Address: validAddress, + Denom: validDenom, + Proofs: nil, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + { + name: "happy path", + msg: MsgCloseAccount{ + Address: validAddress, + Denom: validDenom, + Proofs: &CloseAccountMsgProofs{ + &ZeroBalanceProof{}, + &ZeroBalanceProof{}, + &ZeroBalanceProof{}, + }, + }, + wantErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgDeposit_ValidateBasic(t *testing.T) { + validAddress := sdk.AccAddress("address1").String() + invalidAddress := "invalid_address" + validDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + + tests := []struct { + name string + msg MsgDeposit + wantErr bool + errMsg string + }{ + { + name: "invalid from address", + msg: MsgDeposit{ + FromAddress: invalidAddress, + Denom: validDenom, + Amount: 100, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidAddress.Error(), + }, + { + name: "invalid denom", + msg: MsgDeposit{ + FromAddress: validAddress, + Denom: "", + Amount: 100, + }, + wantErr: true, + errMsg: "invalid denom", + }, + { + name: "zero amount", + msg: MsgDeposit{ + FromAddress: validAddress, + Denom: validDenom, + Amount: 0, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + { + name: "valid message", + msg: MsgDeposit{ + FromAddress: validAddress, + Denom: validDenom, + Amount: 100, + }, + wantErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgApplyPendingBalance_ValidateBasic(t *testing.T) { + validAddress := sdk.AccAddress("address1").String() + invalidAddress := "invalid_address" + validDenom := "factory/sei1ft98au55a24vnu9tvd92cz09pzcfqkm5vlx99w/TEST" + + tests := []struct { + name string + msg MsgApplyPendingBalance + wantErr bool + errMsg string + }{ + { + name: "invalid address", + msg: MsgApplyPendingBalance{ + Address: invalidAddress, + Denom: validDenom, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidAddress.Error(), + }, + { + name: "invalid denom", + msg: MsgApplyPendingBalance{ + Address: validAddress, + Denom: "", + }, + wantErr: true, + errMsg: "invalid denom", + }, + { + name: "missing new decryptable available balance", + msg: MsgApplyPendingBalance{ + Address: validAddress, + Denom: validDenom, + }, + wantErr: true, + errMsg: sdkerrors.ErrInvalidRequest.Error(), + }, + { + name: "valid message", + msg: MsgApplyPendingBalance{ + Address: validAddress, + Denom: validDenom, + NewDecryptableAvailableBalance: "some_balance", + }, + wantErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/confidentialtransfers/types/tx.pb.go b/x/confidentialtransfers/types/tx.pb.go index d090bf241c..8f3378a4d2 100644 --- a/x/confidentialtransfers/types/tx.pb.go +++ b/x/confidentialtransfers/types/tx.pb.go @@ -481,27 +481,6 @@ func (m *MsgApplyPendingBalance) XXX_DiscardUnknown() { var xxx_messageInfo_MsgApplyPendingBalance proto.InternalMessageInfo -func (m *MsgApplyPendingBalance) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *MsgApplyPendingBalance) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *MsgApplyPendingBalance) GetNewDecryptableAvailableBalance() string { - if m != nil { - return m.NewDecryptableAvailableBalance - } - return "" -} - type MsgApplyPendingBalanceResponse struct { } @@ -540,9 +519,9 @@ var xxx_messageInfo_MsgApplyPendingBalanceResponse proto.InternalMessageInfo // Message to be used in close account instruction/transaction type MsgCloseAccount struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - Proof *CloseAccountProof `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + Proofs *CloseAccountMsgProofs `protobuf:"bytes,3,opt,name=proofs,proto3" json:"proofs,omitempty" yaml:"proofs"` } func (m *MsgCloseAccount) Reset() { *m = MsgCloseAccount{} } @@ -578,27 +557,6 @@ func (m *MsgCloseAccount) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCloseAccount proto.InternalMessageInfo -func (m *MsgCloseAccount) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *MsgCloseAccount) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *MsgCloseAccount) GetProof() *CloseAccountProof { - if m != nil { - return m.Proof - } - return nil -} - type MsgCloseAccountResponse struct { } @@ -654,80 +612,80 @@ func init() { func init() { proto.RegisterFile("confidentialtransfers/tx.proto", fileDescriptor_34e86c2ca2c678f9) } var fileDescriptor_34e86c2ca2c678f9 = []byte{ - // 1156 bytes of a gzipped FileDescriptorProto + // 1164 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0xe6, 0x87, 0xe3, 0xbc, 0x84, 0xa6, 0xd9, 0x24, 0xd4, 0xb1, 0xc2, 0x6e, 0x3a, 0x48, - 0x10, 0x10, 0x38, 0x52, 0x5a, 0x15, 0x29, 0x15, 0x2a, 0x76, 0x0a, 0x4a, 0x01, 0x8b, 0x6a, 0x41, - 0x20, 0xb8, 0x58, 0x1b, 0x7b, 0xb2, 0x3b, 0xea, 0x7a, 0x67, 0xb3, 0xb3, 0x69, 0xe2, 0x8a, 0x1b, - 0x20, 0x71, 0xac, 0x84, 0x04, 0x1c, 0xc3, 0xa1, 0x77, 0xee, 0x9c, 0x91, 0x38, 0xf6, 0x88, 0x38, - 0x58, 0x28, 0xb9, 0x70, 0xf6, 0x1f, 0x80, 0x90, 0x67, 0x76, 0xd6, 0xbb, 0xf6, 0x26, 0xcd, 0xda, - 0x6d, 0xc4, 0x6d, 0xe7, 0xc7, 0xfb, 0xbe, 0xef, 0xcd, 0x7b, 0xf3, 0xe6, 0xd9, 0xa0, 0xd5, 0xa9, - 0xbb, 0x47, 0x1a, 0xd8, 0x0d, 0x88, 0xe9, 0x04, 0xbe, 0xe9, 0xb2, 0x3d, 0xec, 0xb3, 0x8d, 0xe0, - 0xa8, 0xe4, 0xf9, 0x34, 0xa0, 0xea, 0x9b, 0x0c, 0x13, 0xfe, 0x55, 0xa7, 0x4e, 0x89, 0x61, 0x52, - 0xb7, 0x4d, 0xe2, 0x96, 0x52, 0x8d,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, + 0x66, 0xf3, 0x76, 0xe9, 0xe2, 0xc7, 0x59, 0xda, 0xc6, 0xbe, 0x83, 0x82, 0x10, 0x1d, 0x85, 0x95, + 0x95, 0x4e, 0x5b, 0x5f, 0x8e, 0xfb, 0x24, 0x70, 0x0d, 0x93, 0x1d, 0x41, 0x99, 0x8d, 0x3f, 0x21, + 0xfd, 0xc4, 0x0e, 0x2e, 0x4c, 0xbe, 0x0c, 0x62, 0x07, 0x27, 0x88, 0x77, 0xb0, 0xba, 0x0f, 0xb3, + 0xdd, 0x33, 0x93, 0xfe, 0xe6, 0x46, 0xa2, 0x8d, 0xc5, 0x30, 0x8e, 0x6a, 0x98, 0x10, 0x12, 0xe9, + 0x6b, 0x82, 0xd2, 0xc1, 0x85, 0xa9, 0x17, 0x4f, 0xd9, 0xf5, 0x53, 0x52, 0xee, 0x60, 0xf5, 0x1b, + 0x05, 0x16, 0x02, 0xd4, 0xb4, 0xb0, 0x87, 0x3d, 0xbb, 0xb6, 0x6b, 0xb9, 0x96, 0x57, 0x47, 0x85, + 0xfc, 0x48, 0xc4, 0x5a, 0xa7, 0xad, 0x17, 0x45, 0x12, 0xb1, 0x5b, 0x61, 0xed, 0xba, 0x48, 0x80, + 0x1b, 0xe6, 0x55, 0x49, 0x58, 0xe1, 0x53, 0xea, 0xa7, 0xb0, 0x98, 0xb2, 0xb3, 0x30, 0xcd, 0x72, + 0xf2, 0x79, 0x70, 0x6a, 0x6c, 0x56, 0x00, 0x3a, 0x90, 0xf3, 0x03, 0x42, 0xf6, 0x68, 0x01, 0x98, + 0x2b, 0xef, 0x65, 0x71, 0x45, 0x5c, 0xc7, 0x2a, 0xb5, 0x1f, 0x30, 0x90, 0xca, 0x42, 0xa7, 0xad, + 0xbf, 0xc2, 0x25, 0x70, 0x58, 0xc3, 0x8c, 0xf0, 0xd5, 0x06, 0xe4, 0xad, 0x83, 0x06, 0x0e, 0x49, + 0x40, 0x0b, 0x33, 0x6b, 0x57, 0xd6, 0x67, 0x36, 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0xb0, 0x30, 0xf8, 0x90, 0xbd, 0x9f, 0x11, + 0x76, 0x00, 0xa1, 0x38, 0x32, 0x82, 0xda, 0x82, 0x29, 0x51, 0xc0, 0x6f, 0x67, 0x04, 0x8b, 0xec, + 0x8a, 0x43, 0xda, 0xa9, 0x5f, 0x43, 0x5e, 0x56, 0xdf, 0xac, 0xa1, 0x11, 0x86, 0xc5, 0x61, 0x0d, + 0xd5, 0xa7, 0x0a, 0x2c, 0xa6, 0xdd, 0xee, 0x4a, 0x46, 0xc0, 0x14, 0x8c, 0xe2, 0x47, 0xa3, 0x63, + 0xc8, 0xd4, 0x79, 0xa2, 0xc0, 0x6c, 0xe2, 0x0e, 0xdf, 0xc9, 0x08, 0x1e, 0x37, 0x2e, 0x6e, 0x8f, + 0x60, 0x2c, 0x24, 0x55, 0xbe, 0xfc, 0xfd, 0x44, 0x53, 0x9e, 0x9d, 0x68, 0xca, 0xdf, 0x27, 0x9a, + 0xf2, 0xe4, 0x54, 0x1b, 0x7b, 0x76, 0xaa, 0x8d, 0xfd, 0x71, 0xaa, 0x8d, 0x7d, 0x75, 0xd7, 0xc6, + 0xa1, 0x73, 0xb0, 0x5b, 0xaa, 0x93, 0xe6, 0x06, 0x45, 0xf8, 0x1d, 0xc1, 0xc4, 0x06, 0x8c, 0x6a, + 0xe3, 0x68, 0xe3, 0x8c, 0x3f, 0xda, 0x5a, 0x3e, 0xa2, 0xbb, 0x39, 0x66, 0x71, 0xf3, 0xbf, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x7c, 0x6f, 0x55, 0x8d, 0x8e, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1598,9 +1556,9 @@ func (m *MsgCloseAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Proof != nil { + if m.Proofs != nil { { - size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Proofs.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1914,8 +1872,8 @@ func (m *MsgCloseAccount) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Proof != nil { - l = m.Proof.Size() + if m.Proofs != nil { + l = m.Proofs.Size() n += 1 + l + sovTx(uint64(l)) } return n @@ -3739,7 +3697,7 @@ func (m *MsgCloseAccount) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Proofs", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3766,10 +3724,10 @@ func (m *MsgCloseAccount) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Proof == nil { - m.Proof = &CloseAccountProof{} + if m.Proofs == nil { + m.Proofs = &CloseAccountMsgProofs{} } - if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Proofs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/confidentialtransfers/types/zk.go b/x/confidentialtransfers/types/zk.go index c8b6405153..c10579c292 100644 --- a/x/confidentialtransfers/types/zk.go +++ b/x/confidentialtransfers/types/zk.go @@ -4,7 +4,6 @@ import ( "github.com/coinbase/kryptology/pkg/bulletproof" "github.com/coinbase/kryptology/pkg/core/curves" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/sei-protocol/sei-cryptography/pkg/zkproofs" ) @@ -48,17 +47,17 @@ func (c *TransferMsgProofs) Validate() error { return nil } -func (c *TransferMsgProofs) ToProto(proofs *TransferProofs) *TransferMsgProofs { +func NewTransferMsgProofs(proofs *TransferProofs) *TransferMsgProofs { return &TransferMsgProofs{ - RemainingBalanceCommitmentValidityProof: c.RemainingBalanceCommitmentValidityProof.ToProto(proofs.RemainingBalanceCommitmentValidityProof), - SenderTransferAmountLoValidityProof: c.RemainingBalanceCommitmentValidityProof.ToProto(proofs.SenderTransferAmountLoValidityProof), - SenderTransferAmountHiValidityProof: c.RemainingBalanceCommitmentValidityProof.ToProto(proofs.SenderTransferAmountHiValidityProof), - RecipientTransferAmountLoValidityProof: c.RemainingBalanceCommitmentValidityProof.ToProto(proofs.RecipientTransferAmountLoValidityProof), - RecipientTransferAmountHiValidityProof: c.RemainingBalanceCommitmentValidityProof.ToProto(proofs.RecipientTransferAmountHiValidityProof), - RemainingBalanceRangeProof: c.RemainingBalanceRangeProof.ToProto(proofs.RemainingBalanceRangeProof), - RemainingBalanceEqualityProof: c.RemainingBalanceEqualityProof.ToProto(proofs.RemainingBalanceEqualityProof), - TransferAmountLoEqualityProof: c.TransferAmountLoEqualityProof.ToProto(proofs.TransferAmountLoEqualityProof), - TransferAmountHiEqualityProof: c.TransferAmountHiEqualityProof.ToProto(proofs.TransferAmountHiEqualityProof), + RemainingBalanceCommitmentValidityProof: NewCiphertextValidityProofProto(proofs.RemainingBalanceCommitmentValidityProof), + SenderTransferAmountLoValidityProof: NewCiphertextValidityProofProto(proofs.SenderTransferAmountLoValidityProof), + SenderTransferAmountHiValidityProof: NewCiphertextValidityProofProto(proofs.SenderTransferAmountHiValidityProof), + RecipientTransferAmountLoValidityProof: NewCiphertextValidityProofProto(proofs.RecipientTransferAmountLoValidityProof), + RecipientTransferAmountHiValidityProof: NewCiphertextValidityProofProto(proofs.RecipientTransferAmountHiValidityProof), + RemainingBalanceRangeProof: NewRangeProofProto(proofs.RemainingBalanceRangeProof), + RemainingBalanceEqualityProof: NewCiphertextCommitmentEqualityProofProto(proofs.RemainingBalanceEqualityProof), + TransferAmountLoEqualityProof: NewCiphertextCiphertextEqualityProofProto(proofs.TransferAmountLoEqualityProof), + TransferAmountHiEqualityProof: NewCiphertextCiphertextEqualityProofProto(proofs.TransferAmountHiEqualityProof), } } @@ -175,8 +174,8 @@ func (w *WithdrawMsgProofs) Validate() error { func (w *WithdrawMsgProofs) NewWithdrawMsgProofs(proofs *WithdrawProofs) *WithdrawMsgProofs { return &WithdrawMsgProofs{ - RemainingBalanceRangeProof: w.RemainingBalanceRangeProof.ToProto(proofs.RemainingBalanceRangeProof), - RemainingBalanceEqualityProof: w.RemainingBalanceEqualityProof.ToProto(proofs.RemainingBalanceEqualityProof), + RemainingBalanceRangeProof: NewRangeProofProto(proofs.RemainingBalanceRangeProof), + RemainingBalanceEqualityProof: NewCiphertextCommitmentEqualityProofProto(proofs.RemainingBalanceEqualityProof), } } @@ -203,7 +202,7 @@ func (c *CiphertextValidityProof) Validate() error { return nil } -func (c *CiphertextValidityProof) ToProto(zkp *zkproofs.CiphertextValidityProof) *CiphertextValidityProof { +func NewCiphertextValidityProofProto(zkp *zkproofs.CiphertextValidityProof) *CiphertextValidityProof { return &CiphertextValidityProof{ Commitment_1: zkp.Commitment1.ToAffineCompressed(), Commitment_2: zkp.Commitment2.ToAffineCompressed(), @@ -253,7 +252,7 @@ func (r *RangeProof) Validate() error { return nil } -func (r *RangeProof) ToProto(zkp *zkproofs.RangeProof) *RangeProof { +func NewRangeProofProto(zkp *zkproofs.RangeProof) *RangeProof { return &RangeProof{ Proof: zkp.Proof.MarshalBinary(), Randomness: zkp.Randomness.ToAffineCompressed(), @@ -293,7 +292,7 @@ func (c *CiphertextCommitmentEqualityProof) Validate() error { return nil } -func (c *CiphertextCommitmentEqualityProof) ToProto(zkp *zkproofs.CiphertextCommitmentEqualityProof) *CiphertextCommitmentEqualityProof { +func NewCiphertextCommitmentEqualityProofProto(zkp *zkproofs.CiphertextCommitmentEqualityProof) *CiphertextCommitmentEqualityProof { return &CiphertextCommitmentEqualityProof{ Y0: zkp.Y0.ToAffineCompressed(), Y1: zkp.Y1.ToAffineCompressed(), @@ -358,7 +357,7 @@ func (c *CiphertextCiphertextEqualityProof) Validate() error { return nil } -func (c *CiphertextCiphertextEqualityProof) ToProto(zkp *zkproofs.CiphertextCiphertextEqualityProof) *CiphertextCiphertextEqualityProof { +func NewCiphertextCiphertextEqualityProofProto(zkp *zkproofs.CiphertextCiphertextEqualityProof) *CiphertextCiphertextEqualityProof { return &CiphertextCiphertextEqualityProof{ Y0: zkp.Y0.ToAffineCompressed(), Y1: zkp.Y1.ToAffineCompressed(), @@ -430,15 +429,13 @@ func (a *Auditor) Validate() error { return nil } -func (a *Auditor) ToProto(transferAuditor *TransferAuditor) *Auditor { +func NewAuditorProto(transferAuditor *TransferAuditor) *Auditor { transferAmountLo := NewCiphertextProto(transferAuditor.EncryptedTransferAmountLo) transferAmountHi := NewCiphertextProto(transferAuditor.EncryptedTransferAmountHi) - cipherTextValidity := CiphertextValidityProof{} - transferAmountLoValidityProof := cipherTextValidity.ToProto(transferAuditor.TransferAmountLoValidityProof) - transferAmountHiValidityProof := cipherTextValidity.ToProto(transferAuditor.TransferAmountHiValidityProof) - ciphertextCiphertextEquality := CiphertextCiphertextEqualityProof{} - transferAmountLoEqualityProof := ciphertextCiphertextEquality.ToProto(transferAuditor.TransferAmountLoEqualityProof) - transferAmountHiEqualityProof := ciphertextCiphertextEquality.ToProto(transferAuditor.TransferAmountHiEqualityProof) + transferAmountLoValidityProof := NewCiphertextValidityProofProto(transferAuditor.TransferAmountLoValidityProof) + transferAmountHiValidityProof := NewCiphertextValidityProofProto(transferAuditor.TransferAmountHiValidityProof) + transferAmountLoEqualityProof := NewCiphertextCiphertextEqualityProofProto(transferAuditor.TransferAmountLoEqualityProof) + transferAmountHiEqualityProof := NewCiphertextCiphertextEqualityProofProto(transferAuditor.TransferAmountHiEqualityProof) return &Auditor{ AuditorAddress: transferAuditor.Address, EncryptedTransferAmountLo: transferAmountLo, @@ -533,7 +530,7 @@ func (p *PubkeyValidityProof) FromProto() (*zkproofs.PubKeyValidityProof, error) }, nil } -func (z *ZeroBalanceProof) ToProto(zkp *zkproofs.ZeroBalanceProof) *ZeroBalanceProof { +func NewZeroBalanceProofProto(zkp *zkproofs.ZeroBalanceProof) *ZeroBalanceProof { return &ZeroBalanceProof{ YP: zkp.Yp.ToAffineCompressed(), YD: zkp.Yd.ToAffineCompressed(), @@ -576,22 +573,22 @@ type CloseAccountProofs struct { ZeroPendingBalanceHiProof *zkproofs.ZeroBalanceProof } -func (c *CloseAccountProof) Validate() error { +func (c *CloseAccountMsgProofs) Validate() error { if c.ZeroAvailableBalanceProof == nil || c.ZeroPendingBalanceLoProof == nil || c.ZeroPendingBalanceHiProof == nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "close account proof is invalid") } return nil } -func (c *CloseAccountProof) ToProto(proofs *CloseAccountProofs) *CloseAccountProof { - return &CloseAccountProof{ - ZeroAvailableBalanceProof: c.ZeroAvailableBalanceProof.ToProto(proofs.ZeroAvailableBalanceProof), - ZeroPendingBalanceLoProof: c.ZeroPendingBalanceLoProof.ToProto(proofs.ZeroPendingBalanceLoProof), - ZeroPendingBalanceHiProof: c.ZeroPendingBalanceHiProof.ToProto(proofs.ZeroPendingBalanceHiProof), +func NewCloseAccountMsgProofs(proofs *CloseAccountProofs) *CloseAccountMsgProofs { + return &CloseAccountMsgProofs{ + ZeroAvailableBalanceProof: NewZeroBalanceProofProto(proofs.ZeroAvailableBalanceProof), + ZeroPendingBalanceLoProof: NewZeroBalanceProofProto(proofs.ZeroPendingBalanceLoProof), + ZeroPendingBalanceHiProof: NewZeroBalanceProofProto(proofs.ZeroPendingBalanceHiProof), } } -func (c *CloseAccountProof) FromProto() (*CloseAccountProofs, error) { +func (c *CloseAccountMsgProofs) FromProto() (*CloseAccountProofs, error) { err := c.Validate() if err != nil { return nil, err diff --git a/x/confidentialtransfers/types/zk.pb.go b/x/confidentialtransfers/types/zk.pb.go index 4ee6ba5af7..fb6c00564f 100644 --- a/x/confidentialtransfers/types/zk.pb.go +++ b/x/confidentialtransfers/types/zk.pb.go @@ -226,6 +226,66 @@ func (m *WithdrawMsgProofs) GetRemainingBalanceEqualityProof() *CiphertextCommit return nil } +type CloseAccountMsgProofs struct { + ZeroAvailableBalanceProof *ZeroBalanceProof `protobuf:"bytes,1,opt,name=zero_available_balance_proof,json=zeroAvailableBalanceProof,proto3" json:"zero_available_balance_proof,omitempty"` + ZeroPendingBalanceLoProof *ZeroBalanceProof `protobuf:"bytes,2,opt,name=zero_pending_balance_lo_proof,json=zeroPendingBalanceLoProof,proto3" json:"zero_pending_balance_lo_proof,omitempty"` + ZeroPendingBalanceHiProof *ZeroBalanceProof `protobuf:"bytes,3,opt,name=zero_pending_balance_hi_proof,json=zeroPendingBalanceHiProof,proto3" json:"zero_pending_balance_hi_proof,omitempty"` +} + +func (m *CloseAccountMsgProofs) Reset() { *m = CloseAccountMsgProofs{} } +func (m *CloseAccountMsgProofs) String() string { return proto.CompactTextString(m) } +func (*CloseAccountMsgProofs) ProtoMessage() {} +func (*CloseAccountMsgProofs) Descriptor() ([]byte, []int) { + return fileDescriptor_71d8640cbb42ddec, []int{3} +} +func (m *CloseAccountMsgProofs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CloseAccountMsgProofs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CloseAccountMsgProofs.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CloseAccountMsgProofs) XXX_Merge(src proto.Message) { + xxx_messageInfo_CloseAccountMsgProofs.Merge(m, src) +} +func (m *CloseAccountMsgProofs) XXX_Size() int { + return m.Size() +} +func (m *CloseAccountMsgProofs) XXX_DiscardUnknown() { + xxx_messageInfo_CloseAccountMsgProofs.DiscardUnknown(m) +} + +var xxx_messageInfo_CloseAccountMsgProofs proto.InternalMessageInfo + +func (m *CloseAccountMsgProofs) GetZeroAvailableBalanceProof() *ZeroBalanceProof { + if m != nil { + return m.ZeroAvailableBalanceProof + } + return nil +} + +func (m *CloseAccountMsgProofs) GetZeroPendingBalanceLoProof() *ZeroBalanceProof { + if m != nil { + return m.ZeroPendingBalanceLoProof + } + return nil +} + +func (m *CloseAccountMsgProofs) GetZeroPendingBalanceHiProof() *ZeroBalanceProof { + if m != nil { + return m.ZeroPendingBalanceHiProof + } + return nil +} + type PubkeyValidityProof struct { Y []byte `protobuf:"bytes,1,opt,name=y,proto3" json:"y,omitempty"` Z []byte `protobuf:"bytes,2,opt,name=z,proto3" json:"z,omitempty"` @@ -235,7 +295,7 @@ func (m *PubkeyValidityProof) Reset() { *m = PubkeyValidityProof{} } func (m *PubkeyValidityProof) String() string { return proto.CompactTextString(m) } func (*PubkeyValidityProof) ProtoMessage() {} func (*PubkeyValidityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{3} + return fileDescriptor_71d8640cbb42ddec, []int{4} } func (m *PubkeyValidityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -293,7 +353,7 @@ func (m *CiphertextValidityProof) Reset() { *m = CiphertextValidityProof func (m *CiphertextValidityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextValidityProof) ProtoMessage() {} func (*CiphertextValidityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{4} + return fileDescriptor_71d8640cbb42ddec, []int{5} } func (m *CiphertextValidityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -360,7 +420,7 @@ func (m *RangeProof) Reset() { *m = RangeProof{} } func (m *RangeProof) String() string { return proto.CompactTextString(m) } func (*RangeProof) ProtoMessage() {} func (*RangeProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{5} + return fileDescriptor_71d8640cbb42ddec, []int{6} } func (m *RangeProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -423,7 +483,7 @@ func (m *CiphertextCommitmentEqualityProof) Reset() { *m = CiphertextCom func (m *CiphertextCommitmentEqualityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextCommitmentEqualityProof) ProtoMessage() {} func (*CiphertextCommitmentEqualityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{6} + return fileDescriptor_71d8640cbb42ddec, []int{7} } func (m *CiphertextCommitmentEqualityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -508,7 +568,7 @@ func (m *CiphertextCiphertextEqualityProof) Reset() { *m = CiphertextCip func (m *CiphertextCiphertextEqualityProof) String() string { return proto.CompactTextString(m) } func (*CiphertextCiphertextEqualityProof) ProtoMessage() {} func (*CiphertextCiphertextEqualityProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{7} + return fileDescriptor_71d8640cbb42ddec, []int{8} } func (m *CiphertextCiphertextEqualityProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -596,7 +656,7 @@ func (m *ZeroBalanceProof) Reset() { *m = ZeroBalanceProof{} } func (m *ZeroBalanceProof) String() string { return proto.CompactTextString(m) } func (*ZeroBalanceProof) ProtoMessage() {} func (*ZeroBalanceProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{8} + return fileDescriptor_71d8640cbb42ddec, []int{9} } func (m *ZeroBalanceProof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -646,135 +706,74 @@ func (m *ZeroBalanceProof) GetZ() []byte { return nil } -type CloseAccountProof struct { - ZeroAvailableBalanceProof *ZeroBalanceProof `protobuf:"bytes,1,opt,name=zero_available_balance_proof,json=zeroAvailableBalanceProof,proto3" json:"zero_available_balance_proof,omitempty"` - ZeroPendingBalanceLoProof *ZeroBalanceProof `protobuf:"bytes,2,opt,name=zero_pending_balance_lo_proof,json=zeroPendingBalanceLoProof,proto3" json:"zero_pending_balance_lo_proof,omitempty"` - ZeroPendingBalanceHiProof *ZeroBalanceProof `protobuf:"bytes,3,opt,name=zero_pending_balance_hi_proof,json=zeroPendingBalanceHiProof,proto3" json:"zero_pending_balance_hi_proof,omitempty"` -} - -func (m *CloseAccountProof) Reset() { *m = CloseAccountProof{} } -func (m *CloseAccountProof) String() string { return proto.CompactTextString(m) } -func (*CloseAccountProof) ProtoMessage() {} -func (*CloseAccountProof) Descriptor() ([]byte, []int) { - return fileDescriptor_71d8640cbb42ddec, []int{9} -} -func (m *CloseAccountProof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CloseAccountProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CloseAccountProof.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *CloseAccountProof) XXX_Merge(src proto.Message) { - xxx_messageInfo_CloseAccountProof.Merge(m, src) -} -func (m *CloseAccountProof) XXX_Size() int { - return m.Size() -} -func (m *CloseAccountProof) XXX_DiscardUnknown() { - xxx_messageInfo_CloseAccountProof.DiscardUnknown(m) -} - -var xxx_messageInfo_CloseAccountProof proto.InternalMessageInfo - -func (m *CloseAccountProof) GetZeroAvailableBalanceProof() *ZeroBalanceProof { - if m != nil { - return m.ZeroAvailableBalanceProof - } - return nil -} - -func (m *CloseAccountProof) GetZeroPendingBalanceLoProof() *ZeroBalanceProof { - if m != nil { - return m.ZeroPendingBalanceLoProof - } - return nil -} - -func (m *CloseAccountProof) GetZeroPendingBalanceHiProof() *ZeroBalanceProof { - if m != nil { - return m.ZeroPendingBalanceHiProof - } - return nil -} - func init() { proto.RegisterType((*TransferMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.TransferMsgProofs") proto.RegisterType((*InitializeAccountMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.InitializeAccountMsgProofs") proto.RegisterType((*WithdrawMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.WithdrawMsgProofs") + proto.RegisterType((*CloseAccountMsgProofs)(nil), "seiprotocol.seichain.confidentialtransfers.CloseAccountMsgProofs") proto.RegisterType((*PubkeyValidityProof)(nil), "seiprotocol.seichain.confidentialtransfers.PubkeyValidityProof") proto.RegisterType((*CiphertextValidityProof)(nil), "seiprotocol.seichain.confidentialtransfers.CiphertextValidityProof") proto.RegisterType((*RangeProof)(nil), "seiprotocol.seichain.confidentialtransfers.RangeProof") proto.RegisterType((*CiphertextCommitmentEqualityProof)(nil), "seiprotocol.seichain.confidentialtransfers.CiphertextCommitmentEqualityProof") proto.RegisterType((*CiphertextCiphertextEqualityProof)(nil), "seiprotocol.seichain.confidentialtransfers.CiphertextCiphertextEqualityProof") proto.RegisterType((*ZeroBalanceProof)(nil), "seiprotocol.seichain.confidentialtransfers.ZeroBalanceProof") - proto.RegisterType((*CloseAccountProof)(nil), "seiprotocol.seichain.confidentialtransfers.CloseAccountProof") } func init() { proto.RegisterFile("confidentialtransfers/zk.proto", fileDescriptor_71d8640cbb42ddec) } var fileDescriptor_71d8640cbb42ddec = []byte{ - // 818 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0xcf, 0x6f, 0xd3, 0x4a, - 0x10, 0xc7, 0xbb, 0xce, 0x6b, 0xfb, 0xba, 0x8d, 0xde, 0x7b, 0x75, 0x1f, 0x02, 0x2a, 0x62, 0x5a, - 0x23, 0x41, 0x05, 0x22, 0x69, 0x52, 0x89, 0x13, 0x52, 0xd5, 0x04, 0xa4, 0x22, 0xb5, 0x52, 0x64, - 0x21, 0x10, 0xbd, 0x58, 0x8e, 0xbd, 0x4d, 0x56, 0x75, 0x76, 0xcd, 0xae, 0x53, 0x62, 0x4b, 0x70, - 0xe1, 0x1f, 0xe0, 0x87, 0x04, 0x12, 0x12, 0x12, 0x9c, 0xf8, 0x57, 0x38, 0xf6, 0xc8, 0x11, 0xb5, - 0x7f, 0x08, 0xc8, 0xeb, 0x1f, 0x89, 0x9d, 0xd0, 0xb4, 0x25, 0x2d, 0xb7, 0xcc, 0xcc, 0xee, 0x7c, - 0x3f, 0x1e, 0xcf, 0x4c, 0x0c, 0x15, 0x93, 0x92, 0x1d, 0x6c, 0x21, 0xe2, 0x62, 0xc3, 0x76, 0x99, - 0x41, 0xf8, 0x0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, 0x8a, 0x7b, 0x61, 0x93, 0xe5, 0xe2, 0x26, 0x7b, 0x93, - 0x83, 0x73, 0x35, 0x9b, 0xf2, 0x78, 0xa1, 0x84, 0x59, 0x9e, 0xc3, 0x2b, 0x3e, 0x62, 0x54, 0x37, - 0xf6, 0x0c, 0x6c, 0x1b, 0x0d, 0x1b, 0x25, 0xa3, 0xd4, 0x3f, 0xc0, 0x77, 0x4f, 0x32, 0x41, 0x59, - 0x52, 0xed, 0x72, 0xa0, 0xb0, 0x1e, 0x0b, 0xa4, 0x1e, 0xe2, 0x05, 0x2c, 0x08, 0x79, 0x07, 0x11, - 0xab, 0x7f, 0x8e, 0x6d, 0x9a, 0x9a, 0xe0, 0x31, 0xe8, 0xd7, 0x43, 0x85, 0x28, 0xb0, 0x49, 0x8f, - 0xd6, 0x6f, 0xe1, 0xd4, 0x97, 0xd8, 0xd8, 0xf5, 0x37, 0xb0, 0x08, 0x55, 0x9f, 0x7c, 0x3d, 0x50, - 0xc0, 0xfe, 0x81, 0x02, 0xbe, 0x1f, 0x28, 0xe0, 0xd5, 0xa1, 0x32, 0xb1, 0x7f, 0xa8, 0x4c, 0x7c, - 0x3b, 0x54, 0x26, 0xb6, 0xd7, 0x9a, 0xd8, 0x6d, 0x75, 0x1a, 0x45, 0x93, 0xb6, 0x4b, 0x1c, 0xe1, - 0xdb, 0xb1, 0xba, 0x30, 0x84, 0x7c, 0xa9, 0x5b, 0x1a, 0xfe, 0xd9, 0xef, 0x7a, 0x0e, 0xe2, 0x8d, - 0x29, 0x71, 0x63, 0xf5, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x49, 0x36, 0xfb, 0xe0, 0x1c, 0x0c, - 0x00, 0x00, + // 813 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0x51, 0x6b, 0xd3, 0x50, + 0x14, 0xc7, 0x77, 0x53, 0xb7, 0xb9, 0x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x01, 0xef, 0x0f, 0x95, 0xb1, 0xfd, 0x43, 0x65, 0xec, 0xe7, 0xa1, 0x32, 0xb6, 0xb5, 0xda, + 0xc0, 0x4e, 0xb3, 0x5d, 0xcf, 0x1b, 0xb4, 0x55, 0xe0, 0x08, 0x3f, 0xe8, 0x4e, 0x85, 0x30, 0xc4, + 0x58, 0x14, 0x3a, 0x85, 0xc1, 0xbf, 0xfe, 0x8e, 0x6b, 0x23, 0x5e, 0x9f, 0x10, 0x3b, 0x56, 0xfe, + 0x04, 0x00, 0x00, 0xff, 0xff, 0x3a, 0xd7, 0x9a, 0x56, 0x20, 0x0c, 0x00, 0x00, } func (m *TransferMsgProofs) Marshal() (dAtA []byte, err error) { @@ -990,6 +989,65 @@ func (m *WithdrawMsgProofs) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *CloseAccountMsgProofs) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CloseAccountMsgProofs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CloseAccountMsgProofs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ZeroPendingBalanceHiProof != nil { + { + size, err := m.ZeroPendingBalanceHiProof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintZk(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.ZeroPendingBalanceLoProof != nil { + { + size, err := m.ZeroPendingBalanceLoProof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintZk(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.ZeroAvailableBalanceProof != nil { + { + size, err := m.ZeroAvailableBalanceProof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintZk(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *PubkeyValidityProof) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1301,65 +1359,6 @@ func (m *ZeroBalanceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *CloseAccountProof) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CloseAccountProof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CloseAccountProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ZeroPendingBalanceHiProof != nil { - { - size, err := m.ZeroPendingBalanceHiProof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintZk(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.ZeroPendingBalanceLoProof != nil { - { - size, err := m.ZeroPendingBalanceLoProof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintZk(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.ZeroAvailableBalanceProof != nil { - { - size, err := m.ZeroAvailableBalanceProof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintZk(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintZk(dAtA []byte, offset int, v uint64) int { offset -= sovZk(v) base := offset @@ -1446,6 +1445,27 @@ func (m *WithdrawMsgProofs) Size() (n int) { return n } +func (m *CloseAccountMsgProofs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ZeroAvailableBalanceProof != nil { + l = m.ZeroAvailableBalanceProof.Size() + n += 1 + l + sovZk(uint64(l)) + } + if m.ZeroPendingBalanceLoProof != nil { + l = m.ZeroPendingBalanceLoProof.Size() + n += 1 + l + sovZk(uint64(l)) + } + if m.ZeroPendingBalanceHiProof != nil { + l = m.ZeroPendingBalanceHiProof.Size() + n += 1 + l + sovZk(uint64(l)) + } + return n +} + func (m *PubkeyValidityProof) Size() (n int) { if m == nil { return 0 @@ -1599,27 +1619,6 @@ func (m *ZeroBalanceProof) Size() (n int) { return n } -func (m *CloseAccountProof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ZeroAvailableBalanceProof != nil { - l = m.ZeroAvailableBalanceProof.Size() - n += 1 + l + sovZk(uint64(l)) - } - if m.ZeroPendingBalanceLoProof != nil { - l = m.ZeroPendingBalanceLoProof.Size() - n += 1 + l + sovZk(uint64(l)) - } - if m.ZeroPendingBalanceHiProof != nil { - l = m.ZeroPendingBalanceHiProof.Size() - n += 1 + l + sovZk(uint64(l)) - } - return n -} - func sovZk(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2208,7 +2207,7 @@ func (m *WithdrawMsgProofs) Unmarshal(dAtA []byte) error { } return nil } -func (m *PubkeyValidityProof) Unmarshal(dAtA []byte) error { +func (m *CloseAccountMsgProofs) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2231,17 +2230,175 @@ func (m *PubkeyValidityProof) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PubkeyValidityProof: wiretype end group for non-group") + return fmt.Errorf("proto: CloseAccountMsgProofs: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PubkeyValidityProof: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CloseAccountMsgProofs: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Y", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ZeroAvailableBalanceProof", wireType) } - var byteLen int + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZk + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZk + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ZeroAvailableBalanceProof == nil { + m.ZeroAvailableBalanceProof = &ZeroBalanceProof{} + } + if err := m.ZeroAvailableBalanceProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ZeroPendingBalanceLoProof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZk + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZk + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ZeroPendingBalanceLoProof == nil { + m.ZeroPendingBalanceLoProof = &ZeroBalanceProof{} + } + if err := m.ZeroPendingBalanceLoProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ZeroPendingBalanceHiProof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZk + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZk + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ZeroPendingBalanceHiProof == nil { + m.ZeroPendingBalanceHiProof = &ZeroBalanceProof{} + } + if err := m.ZeroPendingBalanceHiProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipZk(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthZk + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PubkeyValidityProof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZk + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PubkeyValidityProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubkeyValidityProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Y", wireType) + } + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowZk @@ -3343,164 +3500,6 @@ func (m *ZeroBalanceProof) Unmarshal(dAtA []byte) error { } return nil } -func (m *CloseAccountProof) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowZk - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CloseAccountProof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CloseAccountProof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ZeroAvailableBalanceProof", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowZk - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthZk - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthZk - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ZeroAvailableBalanceProof == nil { - m.ZeroAvailableBalanceProof = &ZeroBalanceProof{} - } - if err := m.ZeroAvailableBalanceProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ZeroPendingBalanceLoProof", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowZk - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthZk - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthZk - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ZeroPendingBalanceLoProof == nil { - m.ZeroPendingBalanceLoProof = &ZeroBalanceProof{} - } - if err := m.ZeroPendingBalanceLoProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ZeroPendingBalanceHiProof", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowZk - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthZk - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthZk - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ZeroPendingBalanceHiProof == nil { - m.ZeroPendingBalanceHiProof = &ZeroBalanceProof{} - } - if err := m.ZeroPendingBalanceHiProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipZk(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthZk - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipZk(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/confidentialtransfers/types/zk_test.go b/x/confidentialtransfers/types/zk_test.go index 5fe85b7d33..3110c755f4 100644 --- a/x/confidentialtransfers/types/zk_test.go +++ b/x/confidentialtransfers/types/zk_test.go @@ -347,12 +347,10 @@ func TestWithdrawMsgProofs_FromProto(t *testing.T) { scalarValue := curves.ED25519().Scalar.New(int(value)) encrypted, randomness, _ := eg.Encrypt(sourceKeypair.PublicKey, value) rangeProof, _ := zkproofs.NewRangeProof(64, int(value), randomness) - rp := RangeProof{} - rangeProofProto := rp.ToProto(rangeProof) + rangeProofProto := NewRangeProofProto(rangeProof) - ep := CiphertextCommitmentEqualityProof{} equalityProof, _ := zkproofs.NewCiphertextCommitmentEqualityProof(sourceKeypair, encrypted, &randomness, &scalarValue) - equalityProofProto := ep.ToProto(equalityProof) + equalityProofProto := NewCiphertextCommitmentEqualityProofProto(equalityProof) tests := []struct { name string @@ -408,12 +406,10 @@ func TestWithdrawMsgProofs_Validate(t *testing.T) { scalarValue := curves.ED25519().Scalar.New(int(value)) encrypted, randomness, _ := eg.Encrypt(sourceKeypair.PublicKey, value) rangeProof, _ := zkproofs.NewRangeProof(64, int(value), randomness) - rp := RangeProof{} - rangeProofProto := rp.ToProto(rangeProof) + rangeProofProto := NewRangeProofProto(rangeProof) - ep := CiphertextCommitmentEqualityProof{} equalityProof, _ := zkproofs.NewCiphertextCommitmentEqualityProof(sourceKeypair, encrypted, &randomness, &scalarValue) - equalityProofProto := ep.ToProto(equalityProof) + equalityProofProto := NewCiphertextCommitmentEqualityProofProto(equalityProof) tests := []struct { name string @@ -459,3 +455,123 @@ func TestWithdrawMsgProofs_Validate(t *testing.T) { }) } } + +func TestCloseAccountMsgProofs_Validate(t *testing.T) { + tests := []struct { + name string + proofs CloseAccountMsgProofs + wantErr bool + errMsg string + }{ + { + name: "valid proofs", + proofs: CloseAccountMsgProofs{ + ZeroAvailableBalanceProof: &ZeroBalanceProof{}, + ZeroPendingBalanceLoProof: &ZeroBalanceProof{}, + ZeroPendingBalanceHiProof: &ZeroBalanceProof{}, + }, + wantErr: false, + }, + { + name: "missing ZeroAvailableBalanceProof", + proofs: CloseAccountMsgProofs{}, + wantErr: true, + errMsg: "close account proof is invalid", + }, + { + name: "missing ZeroPendingBalanceLoProof", + proofs: CloseAccountMsgProofs{ + ZeroAvailableBalanceProof: &ZeroBalanceProof{}, + }, + wantErr: true, + errMsg: "close account proof is invalid", + }, + { + name: "missing ZeroPendingBalanceHiProof", + proofs: CloseAccountMsgProofs{ + ZeroAvailableBalanceProof: &ZeroBalanceProof{}, + ZeroPendingBalanceLoProof: &ZeroBalanceProof{}, + }, + wantErr: true, + errMsg: "close account proof is invalid", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.proofs.Validate() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestCloseAccountMsgProofs_FromProto(t *testing.T) { + tests := []struct { + name string + proofs CloseAccountMsgProofs + wantErr bool + errMsg string + }{ + { + name: "missing ZeroAvailableBalanceProof", + proofs: CloseAccountMsgProofs{}, + wantErr: true, + errMsg: "close account proof is invalid", + }, + { + name: "missing ZeroPendingBalanceLoProof", + proofs: CloseAccountMsgProofs{ + ZeroAvailableBalanceProof: &ZeroBalanceProof{}, + }, + wantErr: true, + errMsg: "close account proof is invalid", + }, + { + name: "missing ZeroPendingBalanceHiProof", + proofs: CloseAccountMsgProofs{ + ZeroAvailableBalanceProof: &ZeroBalanceProof{}, + ZeroPendingBalanceLoProof: &ZeroBalanceProof{}, + }, + wantErr: true, + errMsg: "close account proof is invalid", + }, + { + name: "valid proofs", + proofs: CloseAccountMsgProofs{ + ZeroAvailableBalanceProof: &ZeroBalanceProof{ + YP: curves.ED25519().Point.Random(crand.Reader).ToAffineCompressed(), + YD: curves.ED25519().Point.Random(crand.Reader).ToAffineCompressed(), + Z: curves.ED25519().Scalar.Random(crand.Reader).Bytes(), + }, + ZeroPendingBalanceLoProof: &ZeroBalanceProof{ + YP: curves.ED25519().Point.Random(crand.Reader).ToAffineCompressed(), + YD: curves.ED25519().Point.Random(crand.Reader).ToAffineCompressed(), + Z: curves.ED25519().Scalar.Random(crand.Reader).Bytes(), + }, + ZeroPendingBalanceHiProof: &ZeroBalanceProof{ + YP: curves.ED25519().Point.Random(crand.Reader).ToAffineCompressed(), + YD: curves.ED25519().Point.Random(crand.Reader).ToAffineCompressed(), + Z: curves.ED25519().Scalar.Random(crand.Reader).Bytes(), + }, + }, + wantErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := tt.proofs.FromProto() + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errMsg) + } else { + require.NoError(t, err) + } + }) + } +} From 873d84f7c49f3d841b7536353c0cc96ade34c710 Mon Sep 17 00:00:00 2001 From: mj Date: Tue, 5 Nov 2024 11:09:27 -0500 Subject: [PATCH 8/8] comment --- x/confidentialtransfers/types/msgs.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x/confidentialtransfers/types/msgs.go b/x/confidentialtransfers/types/msgs.go index 78b95640ce..04b0454973 100644 --- a/x/confidentialtransfers/types/msgs.go +++ b/x/confidentialtransfers/types/msgs.go @@ -379,6 +379,9 @@ func (m *MsgWithdraw) GetSigners() []sdk.AccAddress { func (m *MsgWithdraw) FromProto() (*Withdraw, error) { err := m.ValidateBasic() + if err != nil { + return nil, err + } remainingBalanceCommitment, err := m.RemainingBalanceCommitment.FromProto() if err != nil {