Skip to content

Commit

Permalink
remove challenge from ciphertext validity proof
Browse files Browse the repository at this point in the history
  • Loading branch information
dssei committed Oct 17, 2024
1 parent 8da1dff commit 189385e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 94 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/rs/cors v1.8.2
github.com/rs/zerolog v1.30.0
github.com/sei-protocol/goutils v0.0.2
github.com/sei-protocol/sei-cryptography v0.0.0-20241015233858-3ac0ad7e0311
github.com/sei-protocol/sei-cryptography v0.0.0-20241017222230-693c1c3b144f
github.com/sei-protocol/sei-db v0.0.27-0.20240123064153-d6dfa112e760
github.com/sirkon/goproxy v1.4.8
github.com/spf13/cast v1.5.0
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.22.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
Expand Down
7 changes: 5 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,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=
Expand Down Expand Up @@ -769,6 +770,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.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
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=
Expand Down Expand Up @@ -1360,8 +1363,8 @@ github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQp
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
github.com/sei-protocol/sei-cosmos v0.3.37-0.20240923023912-aa7a702d42cc h1:srWLbsoS0NYBIl8OjZOFuPmIeqf+fJTkfsK39MmG3+k=
github.com/sei-protocol/sei-cosmos v0.3.37-0.20240923023912-aa7a702d42cc/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk=
github.com/sei-protocol/sei-cryptography v0.0.0-20241015233858-3ac0ad7e0311 h1:ftF8TbLc08AuPjKmNMgUUmhNdwbH1khOAwJtabknD5c=
github.com/sei-protocol/sei-cryptography v0.0.0-20241015233858-3ac0ad7e0311/go.mod h1:UKxRsOe0NunPs9SY0JFYqcTH5KMWwfLAZHtPEVNGqbk=
github.com/sei-protocol/sei-cryptography v0.0.0-20241017222230-693c1c3b144f h1:UPu7aAxnzCN3ENztPjDlRGuFl4JjTit+H5z3Zu1c4DA=
github.com/sei-protocol/sei-cryptography v0.0.0-20241017222230-693c1c3b144f/go.mod h1:UKxRsOe0NunPs9SY0JFYqcTH5KMWwfLAZHtPEVNGqbk=
github.com/sei-protocol/sei-db v0.0.44 h1:HMgcyDTQlmXdJysHJxmIo66EKeXn1CSQT9qXDnxjJgI=
github.com/sei-protocol/sei-db v0.0.44/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI=
github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I=
Expand Down
4 changes: 2 additions & 2 deletions proto/confidentialtransfers/zk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ message CiphertextValidityProof {
// Second commitment
bytes commitment_2 = 2;

bytes challenge = 3;

// First response
bytes response_1 = 4;

// Second response
bytes response_2 = 5;
}
21 changes: 21 additions & 0 deletions x/confidentialtransfers/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,25 @@ func TestMsgTransfer_FromProto(t *testing.T) {
assert.True(t, destinationCipherAmountHi.D.Equal(result.RecipientTransferAmountHi.D))
assert.True(t, remainingBalanceCiphertext.C.Equal(result.RemainingBalanceCommitment.C))
assert.True(t, remainingBalanceCiphertext.D.Equal(result.RemainingBalanceCommitment.D))

// Make sure the proofs are valid
assert.True(t, zkproofs.VerifyCiphertextValidity(
sourceCiphertextAmountLoValidityProof,
sourceKeypair.PublicKey,
sourceCiphertextAmountLo))

assert.True(t, zkproofs.VerifyCiphertextValidity(
sourceCiphertextAmountHiValidityProof,
sourceKeypair.PublicKey,
sourceCiphertextAmountHi))

assert.True(t, zkproofs.VerifyCiphertextValidity(
destinationCipherAmountLoValidityProof,
destinationKeypair.PublicKey,
destinationCipherAmountLo))

assert.True(t, zkproofs.VerifyCiphertextValidity(
destinationCipherAmountHiValidityProof,
destinationKeypair.PublicKey,
destinationCipherAmountHi))
}
7 changes: 0 additions & 7 deletions x/confidentialtransfers/types/zk.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (c *CiphertextValidityProof) ToProto(zkp *zkproofs.CiphertextValidityProof)
return &CiphertextValidityProof{
Commitment_1: zkp.Commitment1.ToAffineCompressed(),
Commitment_2: zkp.Commitment2.ToAffineCompressed(),
Challenge: zkp.Challenge.Bytes(),
Response_1: zkp.Response1.Bytes(),
Response_2: zkp.Response2.Bytes(),
}
Expand All @@ -77,11 +76,6 @@ func (c *CiphertextValidityProof) FromProto() (*zkproofs.CiphertextValidityProof
return nil, err
}

challenge, err := ed25519Curve.Scalar.SetBytes(c.Challenge)
if err != nil {
return nil, err
}

r1, err := ed25519Curve.Scalar.SetBytes(c.Response_1)
if err != nil {
return nil, err
Expand All @@ -94,7 +88,6 @@ func (c *CiphertextValidityProof) FromProto() (*zkproofs.CiphertextValidityProof
return &zkproofs.CiphertextValidityProof{
Commitment1: c1,
Commitment2: c2,
Challenge: challenge,
Response1: r1,
Response2: r2,
}, nil
Expand Down
112 changes: 30 additions & 82 deletions x/confidentialtransfers/types/zk.pb.go

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

0 comments on commit 189385e

Please sign in to comment.