diff --git a/go.mod b/go.mod index 6261f16..82805e7 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.21 require ( github.com/bwesterb/go-ristretto v1.2.3 github.com/coinbase/kryptology v1.8.0 - github.com/ethereum/go-ethereum v1.13.15 github.com/gtank/merlin v0.1.1 github.com/stretchr/testify v1.9.0 golang.org/x/crypto v0.27.0 @@ -16,6 +15,7 @@ require ( github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index b9a4c91..d2ba48b 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,15 @@ -filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= -filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/bwesterb/go-ristretto v1.2.3 h1:1w53tCkGhCQ5djbat3+MH0BAQ5Kfgbt56UZQ/JMzngw= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/ethereum/go-ethereum v1.13.15 h1:U7sSGYGo4SPjP6iNIifNoyIAiNjrmQkz6EwQG+/EZWo= github.com/ethereum/go-ethereum v1.13.15/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -24,10 +22,12 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= 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/sei-protocol/coinbase-kryptology v0.0.0-20241015231206-08f61b7965cd h1:R/g4pa6pgegLAAt1NTrO1qVJ3uZH9hfcMcc4yLz1cgg= diff --git a/pkg/encryption/aes.go b/pkg/encryption/aes.go index c00fffc..e58a1e2 100644 --- a/pkg/encryption/aes.go +++ b/pkg/encryption/aes.go @@ -3,7 +3,6 @@ package encryption import ( "crypto/aes" "crypto/cipher" - "crypto/ecdsa" "crypto/rand" "crypto/sha256" "encoding/base64" @@ -12,33 +11,19 @@ import ( "io" "math/big" - "github.com/ethereum/go-ethereum/crypto/secp256k1" - "golang.org/x/crypto/hkdf" ) -// GenerateKey generates a new ECDSA private key using the secp256k1 curve. -func GenerateKey() (*ecdsa.PrivateKey, error) { - return ecdsa.GenerateKey(secp256k1.S256(), rand.Reader) -} - -// GetAESKey derives a 32-byte AES key using the provided ECDSA private key and denomination string. -// It employs HKDF with SHA-256, using the ECDSA private key bytes and a SHA-256 hash of the denom as salt. -func GetAESKey(privKey ecdsa.PrivateKey, denom string) ([]byte, error) { - if privKey.D == nil { - return nil, fmt.Errorf("private key D is nil") +// GetAESKey derives a 32-byte AES key using the provided bytes. +// It employs HKDF with SHA-256, using the private key bytes. +// No additional salt is added here so ensure that the privateBytes are already salted or hashed. +func GetAESKey(privateBytes []byte) ([]byte, error) { + if len(privateBytes) == 0 { + return nil, fmt.Errorf("bytes is empty") } - if len(denom) == 0 { - return nil, fmt.Errorf("denom is empty") - } - // Convert the ECDSA private key to bytes - privKeyBytes := privKey.D.Bytes() - - // Use a SHA-256 hash of the denom string as the salt - salt := sha256.Sum256([]byte(denom)) // Create an HKDF reader using SHA-256 - hkdf := hkdf.New(sha256.New, privKeyBytes, salt[:], []byte("aes key derivation")) + hkdf := hkdf.New(sha256.New, privateBytes, nil, []byte("aes key derivation")) // Allocate a 32-byte array for the AES key aesKey := make([]byte, 32) diff --git a/pkg/encryption/aes_test.go b/pkg/encryption/aes_test.go index 095d01a..0a7f493 100644 --- a/pkg/encryption/aes_test.go +++ b/pkg/encryption/aes_test.go @@ -1,9 +1,9 @@ package encryption import ( - "crypto/ecdsa" "math/big" "testing" + "time" "github.com/stretchr/testify/require" ) @@ -16,57 +16,37 @@ const ( func TestGetAESKey(t *testing.T) { tests := []struct { name string - privateKey *ecdsa.PrivateKey + privateKey []byte denom string expectEqual bool - anotherKey *ecdsa.PrivateKey + anotherKey []byte anotherDenom string }{ { name: "Deterministic Key Generation", - privateKey: generateTestKey(t), - denom: TestDenom, + privateKey: generateTestKey(), expectEqual: true, }, - { - name: "Different Denom (Salt) Generates Different Key", - privateKey: generateTestKey(t), - denom: TestDenom, - anotherDenom: TestDenom + "1", - expectEqual: false, - }, - { - name: "Different Denom (Salt) of same length Generates Different Key", - privateKey: generateTestKey(t), - denom: TestDenom + "1", - anotherDenom: TestDenom + "2", - expectEqual: false, - }, { name: "Different PrivateKey Generates Different Key", - privateKey: generateTestKey(t), - denom: TestDenom + "N", - anotherKey: generateTestKey(t), + privateKey: generateTestKey(), + anotherKey: generateTestKey(), expectEqual: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - aesPK, err := GetAESKey(*tt.privateKey, tt.denom) + aesPK, err := GetAESKey(tt.privateKey) require.Nil(t, err, "Should not have error here") if tt.anotherKey != nil { - aesPKDiff, err := GetAESKey(*tt.anotherKey, tt.denom) + aesPKDiff, err := GetAESKey(tt.anotherKey) require.Nil(t, err) require.NotEqual(t, aesPK, aesPKDiff, "PK should be different for different private keys") - } else if tt.anotherDenom != "" { - aesPKDiff, err := GetAESKey(*tt.privateKey, tt.anotherDenom) - require.Nil(t, err) - require.NotEqual(t, aesPK, aesPKDiff, "PK should be different for different salts") } else { - aesPKAgain, err := GetAESKey(*tt.privateKey, tt.denom) + aesPKAgain, err := GetAESKey(tt.privateKey) require.Nil(t, err, "Should not have error here") if tt.expectEqual { require.Equal(t, aesPK, aesPKAgain, "PK should be deterministically generated") @@ -80,16 +60,8 @@ func TestGetAESKey(t *testing.T) { func TestGetAESKey_InvalidInput(t *testing.T) { // Nil private key - _, err := GetAESKey(*new(ecdsa.PrivateKey), TestDenom) + _, err := GetAESKey([]byte{}) require.Error(t, err, "Should return error for nil private key") - - invalidPrivateKey := &ecdsa.PrivateKey{ /* Invalid key data */ } - _, err = GetAESKey(*invalidPrivateKey, TestDenom) - require.Error(t, err, "Should return error for invalid private key") - - validPrivateKey := generateTestKey(t) - _, err = GetAESKey(*validPrivateKey, "") - require.Error(t, err, "Should not allow empty denom(salt)") } func TestAESEncryptionDecryption(t *testing.T) { @@ -218,8 +190,7 @@ func TestDecryptAESGCM_InvalidCiphertext(t *testing.T) { } // Helper function to generate a test private key -func generateTestKey(t *testing.T) *ecdsa.PrivateKey { - privateKey, err := GenerateKey() - require.Nil(t, err, "Failed to generate private key") - return privateKey +func generateTestKey() []byte { + randomString := time.Now() + return []byte(randomString.String()) } diff --git a/pkg/encryption/elgamal/common.go b/pkg/encryption/elgamal/common.go index fe5e42a..e624bdd 100644 --- a/pkg/encryption/elgamal/common.go +++ b/pkg/encryption/elgamal/common.go @@ -1,7 +1,6 @@ package elgamal import ( - "crypto/ecdsa" "crypto/sha256" "io" @@ -13,11 +12,12 @@ import ( const H_STRING = "gPt25pi0eDphSiXWu0BIeIvyVATCtwhslTqfqvNhW2c" // KeyGen generates a new key pair for the Twisted ElGamal encryption scheme. -func (teg TwistedElGamal) KeyGen(privateKey ecdsa.PrivateKey, denom string) (*KeyPair, error) { +// The private key is derived from the provided privateBytes and denom string. Ensure that the privateBytes passed is not exposed. +func (teg TwistedElGamal) KeyGen(privateBytes []byte) (*KeyPair, error) { // Fixed base point H H := teg.GetH() - s, err := teg.getPrivateKey(privateKey, denom) + s, err := teg.getPrivateKeyFromBytes(privateBytes) if err != nil { return nil, err } @@ -47,17 +47,11 @@ func (teg TwistedElGamal) GetH() curves.Point { return teg.curve.Point.Hash(bytes) } -// getPrivateKey derives a private key for the ElGamal cryptosystem. -// It takes an ECDSA private key and a denomination string to generate the scalar. -func (teg TwistedElGamal) getPrivateKey(privateKey ecdsa.PrivateKey, denom string) (curves.Scalar, error) { - // Convert the ECDSA private key to bytes - privKeyBytes := privateKey.D.Bytes() - - // Hash the denom to get a salt. - salt := sha256.Sum256([]byte(denom)) - +// Creates an el gamal private key from the provided bytes. +// No additional salt is added here so ensure that the privateBytes are already salted or hashed. +func (teg TwistedElGamal) getPrivateKeyFromBytes(privateBytes []byte) (curves.Scalar, error) { // Create an HKDF reader using SHA-256 - hkdf := hkdf.New(sha256.New, privKeyBytes, salt[:], []byte("elgamal scalar derivation")) + hkdf := hkdf.New(sha256.New, privateBytes, nil, []byte("elgamal scalar derivation")) // Generate 64 bytes of randomness from HKDF output var scalarBytes [64]byte diff --git a/pkg/encryption/elgamal/encryption_test.go b/pkg/encryption/elgamal/encryption_test.go index 5d4fb45..e22710e 100644 --- a/pkg/encryption/elgamal/encryption_test.go +++ b/pkg/encryption/elgamal/encryption_test.go @@ -13,46 +13,32 @@ import ( const DefaultTestDenom = "factory/sei1239081236472sd/testToken" func TestKeyGeneration(t *testing.T) { - privateKey, err := testutils.GenerateKey() - require.Nil(t, err) + privateKey := testutils.GenerateKey() eg := NewTwistedElgamal() - keyPair, err := eg.KeyGen(*privateKey, DefaultTestDenom) + keyPair, err := eg.KeyGen(*privateKey) require.Nil(t, err) // Test that keyPair is deterministically generated - keyPairAgain, err := eg.KeyGen(*privateKey, DefaultTestDenom) + keyPairAgain, err := eg.KeyGen(*privateKey) require.Nil(t, err) require.Equal(t, keyPair, keyPairAgain, "PK should be deterministically generated") - // Test that changing the salt should generate a different key - altDenom := "factory/sei1239081236470/testToken1" - keyPairDiffSalt, err := eg.KeyGen(*privateKey, altDenom) - require.Nil(t, err) - require.NotEqual(t, keyPair, keyPairDiffSalt, "PK should be different for different salt") - - // Test same thing for salt of same length - altDenom = "factory/sei1239081236470/testTokeN" - keyPairDiffSalt, err = eg.KeyGen(*privateKey, altDenom) - require.Nil(t, err) - require.NotEqual(t, keyPair, keyPairDiffSalt, "PK should be different for different salt") - // Test that different privateKey should generate different PK - altPrivateKey, err := testutils.GenerateKey() - require.Nil(t, err) - keyPairDiffPK, err := eg.KeyGen(*altPrivateKey, altDenom) + altPrivateKey := testutils.GenerateKey() + keyPairDiffPK, err := eg.KeyGen(*altPrivateKey) require.Nil(t, err) require.NotEqual(t, keyPair, keyPairDiffPK, "PK should be different for different ESDCA Private Key") } func TestEncryptionDecryption(t *testing.T) { - privateKey, _ := testutils.GenerateKey() - altPrivateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() + altPrivateKey := testutils.GenerateKey() eg := NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) - altKeys, _ := eg.KeyGen(*altPrivateKey, DefaultTestDenom) + keys, _ := eg.KeyGen(*privateKey) + altKeys, _ := eg.KeyGen(*altPrivateKey) // Happy Path value := big.NewInt(108) @@ -83,11 +69,10 @@ func TestEncryptionDecryption(t *testing.T) { // Due to the size of 48 bit numbers, this test takes a really long time (~1hr) to run. func Test48BitEncryptionDecryption(t *testing.T) { - privateKey, err := testutils.GenerateKey() - require.Nil(t, err) + privateKey := testutils.GenerateKey() eg := NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + keys, _ := eg.KeyGen(*privateKey) // First decrypt a 32 bit number (sets up the decryptor for a later test) value := big.NewInt(108092) @@ -124,13 +109,13 @@ func Test48BitEncryptionDecryption(t *testing.T) { } func TestAddCiphertext(t *testing.T) { - privateKey, _ := testutils.GenerateKey() - altPrivateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() + altPrivateKey := testutils.GenerateKey() eg := NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) - altKeys, _ := eg.KeyGen(*altPrivateKey, DefaultTestDenom) + keys, _ := eg.KeyGen(*privateKey) + altKeys, _ := eg.KeyGen(*altPrivateKey) // Happy Path value1 := big.NewInt(30842) @@ -172,8 +157,8 @@ func TestAddCiphertext(t *testing.T) { func TestTwistedElGamal_InvalidCiphertext(t *testing.T) { eg := NewTwistedElgamal() - privateKey, _ := testutils.GenerateKey() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + privateKey := testutils.GenerateKey() + keys, _ := eg.KeyGen(*privateKey) invalidCt := &Ciphertext{} @@ -187,8 +172,8 @@ func TestTwistedElGamal_NilPrivateKey(t *testing.T) { eg := NewTwistedElgamal() // Generate a valid key pair for comparison - privateKey, _ := testutils.GenerateKey() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + privateKey := testutils.GenerateKey() + keys, _ := eg.KeyGen(*privateKey) // Encrypt a value with a valid public key value := big.NewInt(12345) @@ -206,8 +191,8 @@ func TestTwistedElGamal_EncryptDecryptWithRand(t *testing.T) { eg := NewTwistedElgamal() // Generate a valid key pair for comparison - privateKey, _ := testutils.GenerateKey() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + privateKey := testutils.GenerateKey() + keys, _ := eg.KeyGen(*privateKey) message := big.NewInt(555555555) randomFactor := curves.ED25519().Scalar.Random(rand.Reader) @@ -224,8 +209,8 @@ func TestTwistedElGamal_EncryptMessageTwice(t *testing.T) { eg := NewTwistedElgamal() // Generate a valid key pair for comparison - privateKey, _ := testutils.GenerateKey() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + privateKey := testutils.GenerateKey() + keys, _ := eg.KeyGen(*privateKey) message := big.NewInt(555555555) randomFactor := curve.Scalar.Random(rand.Reader) @@ -240,8 +225,8 @@ func TestTwistedElGamal_DecryptWithZeroBits(t *testing.T) { eg := NewTwistedElgamal() // Generate a valid key pair for comparison - privateKey, _ := testutils.GenerateKey() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + privateKey := testutils.GenerateKey() + keys, _ := eg.KeyGen(*privateKey) message := big.NewInt(555555555) randomFactor := curve.Scalar.Random(rand.Reader) @@ -266,8 +251,8 @@ func TestTwistedElGamal_EncryptInvalidRandomFactor(t *testing.T) { eg := NewTwistedElgamal() // Generate a valid key pair for comparison - privateKey, _ := testutils.GenerateKey() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + privateKey := testutils.GenerateKey() + keys, _ := eg.KeyGen(*privateKey) // Test with nil public key _, _, err := eg.encryptWithRand(keys.PublicKey, big.NewInt(12345), nil) @@ -279,8 +264,8 @@ func TestTwistedElGamal_EncryptBoundaryValues(t *testing.T) { eg := NewTwistedElgamal() // Generate a valid key pair for comparison - privateKey, _ := testutils.GenerateKey() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + privateKey := testutils.GenerateKey() + keys, _ := eg.KeyGen(*privateKey) // Test with the smallest possible value (0) _, _, err := eg.Encrypt(keys.PublicKey, big.NewInt(0)) diff --git a/pkg/encryption/elgamal/types_test.go b/pkg/encryption/elgamal/types_test.go index 9c890c6..428ca56 100644 --- a/pkg/encryption/elgamal/types_test.go +++ b/pkg/encryption/elgamal/types_test.go @@ -10,10 +10,10 @@ import ( ) func TestCiphertext_MarshalJSON(t *testing.T) { - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, DefaultTestDenom) + keys, _ := eg.KeyGen(*privateKey) value := big.NewInt(108) ciphertext, _, _ := eg.Encrypt(keys.PublicKey, value) diff --git a/pkg/testing/utils.go b/pkg/testing/utils.go index 6e9f8d0..4eb7fef 100644 --- a/pkg/testing/utils.go +++ b/pkg/testing/utils.go @@ -1,12 +1,11 @@ package testing import ( - "crypto/ecdsa" - "crypto/rand" - "github.com/ethereum/go-ethereum/crypto/secp256k1" + "time" ) -// GenerateKey generates a new ECDSA key pair. -func GenerateKey() (*ecdsa.PrivateKey, error) { - return ecdsa.GenerateKey(secp256k1.S256(), rand.Reader) +// GenerateKey generates a new private bytes object used to dervie the keypair. +func GenerateKey() *[]byte { + result := []byte(time.Now().String()) + return &result } diff --git a/pkg/zkproofs/ciphertext_ciphertext_equality_test.go b/pkg/zkproofs/ciphertext_ciphertext_equality_test.go index 70295a5..3a7a20b 100644 --- a/pkg/zkproofs/ciphertext_ciphertext_equality_test.go +++ b/pkg/zkproofs/ciphertext_ciphertext_equality_test.go @@ -55,17 +55,17 @@ func TestCiphertextCiphertextEqualityProof(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // Key generation - sourcePrivateKey, _ := testutils.GenerateKey() - destPrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() + destPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) - destinationKeypair, _ := eg.KeyGen(*destPrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) + destinationKeypair, _ := eg.KeyGen(*destPrivateKey) var actualDestinationPubkey *curves.Point if tt.useDifferentPublicKey { - altDestPrivateKey, _ := testutils.GenerateKey() + altDestPrivateKey := testutils.GenerateKey() // Generate an alternative keypair for destination - altDestinationKeypair, _ := eg.KeyGen(*altDestPrivateKey, TestDenom) + altDestinationKeypair, _ := eg.KeyGen(*altDestPrivateKey) actualDestinationPubkey = &altDestinationKeypair.PublicKey } else { actualDestinationPubkey = &destinationKeypair.PublicKey @@ -112,11 +112,11 @@ func TestCiphertextCiphertextEqualityProof(t *testing.T) { func TestCiphertextCiphertextEqualityProof_EdgeCases(t *testing.T) { t.Run("Zero Amounts", func(t *testing.T) { // Key generation - sourcePrivateKey, _ := testutils.GenerateKey() - destPrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() + destPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) - destinationKeypair, _ := eg.KeyGen(*destPrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) + destinationKeypair, _ := eg.KeyGen(*destPrivateKey) amount := big.NewInt(0) @@ -152,12 +152,12 @@ func TestCiphertextCiphertextEqualityProof_EdgeCases(t *testing.T) { t.Run("Maximum Amount", func(t *testing.T) { // Key generation - sourcePrivateKey, _ := testutils.GenerateKey() - destPrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() + destPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) - destinationKeypair, _ := eg.KeyGen(*destPrivateKey, TestDenom) + destinationKeypair, _ := eg.KeyGen(*destPrivateKey) amount := big.NewInt(1 << 60) // A large amount to test scalability @@ -194,11 +194,11 @@ func TestCiphertextCiphertextEqualityProof_EdgeCases(t *testing.T) { } func TestCiphertextCiphertextEqualityProof_UnmarshalJSON_Valid(t *testing.T) { - sourcePrivateKey, _ := testutils.GenerateKey() - destPrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() + destPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) - destinationKeypair, _ := eg.KeyGen(*destPrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) + destinationKeypair, _ := eg.KeyGen(*destPrivateKey) amount := big.NewInt(100) @@ -241,11 +241,11 @@ func TestCiphertextCiphertextEqualityProof_UnmarshalJSON_Valid(t *testing.T) { // Invalid input tests for NewCiphertextCiphertextEqualityProof func TestNewCiphertextCiphertextEqualityProof_InvalidInputs(t *testing.T) { - sourcePrivateKey, _ := testutils.GenerateKey() - destPrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() + destPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) - destinationKeypair, _ := eg.KeyGen(*destPrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) + destinationKeypair, _ := eg.KeyGen(*destPrivateKey) amount := big.NewInt(100) @@ -323,11 +323,11 @@ func TestNewCiphertextCiphertextEqualityProof_InvalidInputs(t *testing.T) { // Invalid input tests for VerifyCiphertextCiphertextEquality func TestVerifyCiphertextCiphertextEquality_InvalidInputs(t *testing.T) { - sourcePrivateKey, _ := testutils.GenerateKey() - destPrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() + destPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) - destinationKeypair, _ := eg.KeyGen(*destPrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) + destinationKeypair, _ := eg.KeyGen(*destPrivateKey) amount := big.NewInt(100) @@ -456,11 +456,11 @@ func TestVerifyCiphertextCiphertextEquality_InvalidInputs(t *testing.T) { // Test that the proof is still valid for cases where Ciphertext.D is the identity point. func TestCiphertextCiphertextEqualityProof_IdentityD(t *testing.T) { // Key generation - sourcePrivateKey, _ := testutils.GenerateKey() - destPrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() + destPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) - destinationKeypair, _ := eg.KeyGen(*destPrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) + destinationKeypair, _ := eg.KeyGen(*destPrivateKey) // Encrypt the source amount sourceCiphertext, _, err := eg.Encrypt(sourceKeypair.PublicKey, big.NewInt(100)) diff --git a/pkg/zkproofs/ciphertext_commitment_equality_test.go b/pkg/zkproofs/ciphertext_commitment_equality_test.go index e03ab0d..30235dc 100644 --- a/pkg/zkproofs/ciphertext_commitment_equality_test.go +++ b/pkg/zkproofs/ciphertext_commitment_equality_test.go @@ -54,9 +54,9 @@ func TestCiphertextCommitmentEqualityProof(t *testing.T) { tt := tt // Capture range variable t.Run(tt.name, func(t *testing.T) { // Key generation - sourcePrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) // Encrypt the source amount sourceCiphertext, sourceRandomness, err := eg.Encrypt(sourceKeypair.PublicKey, tt.sourceAmount) @@ -121,9 +121,9 @@ func TestCiphertextCommitmentEqualityProof(t *testing.T) { } func TestCiphertextCommitmentEqualityProof_MarshalUnmarshalJSON(t *testing.T) { - sourcePrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) amount := big.NewInt(232436) // Encrypt the source amount @@ -161,9 +161,9 @@ func TestCiphertextCommitmentEqualityProof_MarshalUnmarshalJSON(t *testing.T) { } func TestNewCiphertextCommitmentEqualityProof_InvalidInput(t *testing.T) { - sourcePrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) amount := big.NewInt(100) @@ -221,9 +221,9 @@ func TestNewCiphertextCommitmentEqualityProof_InvalidInput(t *testing.T) { } func TestVerifyCiphertextCommitmentEquality_InvalidInput(t *testing.T) { - sourcePrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) amount := big.NewInt(100) @@ -331,9 +331,9 @@ func TestVerifyCiphertextCommitmentEquality_InvalidInput(t *testing.T) { // Test that the proof is still valid for cases where Ciphertext.D is the identity point. func TestCiphertextCommitmentEqualityProof_IdentityD(t *testing.T) { // Key generation - sourcePrivateKey, _ := testutils.GenerateKey() + sourcePrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey, TestDenom) + sourceKeypair, _ := eg.KeyGen(*sourcePrivateKey) // Encrypt the source amount sourceCiphertext, _, err := eg.Encrypt(sourceKeypair.PublicKey, big.NewInt(100)) diff --git a/pkg/zkproofs/ciphertext_validity_test.go b/pkg/zkproofs/ciphertext_validity_test.go index cb2a0ec..9ba713d 100644 --- a/pkg/zkproofs/ciphertext_validity_test.go +++ b/pkg/zkproofs/ciphertext_validity_test.go @@ -12,12 +12,12 @@ import ( ) func TestValidityProof(t *testing.T) { - privateKey, _ := testutils.GenerateKey() - altPrivateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() + altPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, TestDenom) - altKeys, _ := eg.KeyGen(*altPrivateKey, TestDenom) + keys, _ := eg.KeyGen(*privateKey) + altKeys, _ := eg.KeyGen(*altPrivateKey) message12 := big.NewInt(12) ciphertext12, randomness12, err := eg.Encrypt(keys.PublicKey, message12) @@ -63,9 +63,9 @@ func TestValidityProof(t *testing.T) { } func TestCiphertextValidityProof_MarshalUnmarshalJSON(t *testing.T) { - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, TestDenom) + keys, _ := eg.KeyGen(*privateKey) message12 := big.NewInt(12) ciphertext12, randomness12, _ := eg.Encrypt(keys.PublicKey, message12) @@ -89,9 +89,9 @@ func TestCiphertextValidityProof_MarshalUnmarshalJSON(t *testing.T) { } func TestNewCiphertextValidityProof_InvalidInput(t *testing.T) { - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, TestDenom) + keys, _ := eg.KeyGen(*privateKey) amount := big.NewInt(100) // Encrypt the amount using source and destination public keys @@ -135,9 +135,9 @@ func TestNewCiphertextValidityProof_InvalidInput(t *testing.T) { } func TestVerifyCiphertextValidityProof_Invalid_Input(t *testing.T) { - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, TestDenom) + keys, _ := eg.KeyGen(*privateKey) amount := big.NewInt(100) // Encrypt the amount using source and destination public keys diff --git a/pkg/zkproofs/pubkey_validity_test.go b/pkg/zkproofs/pubkey_validity_test.go index 2d8247b..16fbe6b 100644 --- a/pkg/zkproofs/pubkey_validity_test.go +++ b/pkg/zkproofs/pubkey_validity_test.go @@ -11,12 +11,12 @@ import ( ) func TestPubKeyValidityProof(t *testing.T) { - privateKey, _ := testutils.GenerateKey() - altPrivateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() + altPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, TestDenom) - altKeys, _ := eg.KeyGen(*altPrivateKey, TestDenom) + keys, _ := eg.KeyGen(*privateKey) + altKeys, _ := eg.KeyGen(*altPrivateKey) // Prove knowledge of the private key proof, err := NewPubKeyValidityProof(keys.PublicKey, keys.PrivateKey) @@ -37,9 +37,9 @@ func TestPubKeyValidityProof(t *testing.T) { } func TestPubKeyValidityProof_MarshalUnmarshalJSON(t *testing.T) { - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, TestDenom) + keys, _ := eg.KeyGen(*privateKey) original, err := NewPubKeyValidityProof(keys.PublicKey, keys.PrivateKey) require.NoError(t, err, "Proof generation should not produce an error") @@ -58,9 +58,9 @@ func TestPubKeyValidityProof_MarshalUnmarshalJSON(t *testing.T) { } func TestNewPubKeyValidityProof_InvalidInput(t *testing.T) { - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keys, _ := eg.KeyGen(*privateKey, TestDenom) + keys, _ := eg.KeyGen(*privateKey) _, err := NewPubKeyValidityProof(nil, keys.PrivateKey) require.Error(t, err, "Generating proof with nil public key should produce an error") @@ -70,11 +70,10 @@ func TestNewPubKeyValidityProof_InvalidInput(t *testing.T) { } func TestVerifyPubKeyValidityProof_InvalidInput(t *testing.T) { - privateKey, err := testutils.GenerateKey() - require.Nil(t, err) + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keys, err := eg.KeyGen(*privateKey, TestDenom) + keys, err := eg.KeyGen(*privateKey) require.Nil(t, err) // Prove knowledge of the private key diff --git a/pkg/zkproofs/range_test.go b/pkg/zkproofs/range_test.go index 3b2bef3..112422e 100644 --- a/pkg/zkproofs/range_test.go +++ b/pkg/zkproofs/range_test.go @@ -31,11 +31,10 @@ func TestValueIsInRange(t *testing.T) { v, _ := curve.Scalar.SetBigInt(value) n := 64 // the range is [0, 2^64] - privateKey, err := testutils.GenerateKey() - require.Nil(t, err, "Error generating private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keyPair, err := eg.KeyGen(*privateKey, TestDenom) + keyPair, err := eg.KeyGen(*privateKey) require.Nil(t, err, "Error generating key pair") ciphertext, gamma, _ := eg.Encrypt(keyPair.PublicKey, value) @@ -73,11 +72,10 @@ func TestRangeAttacksAreInfeasible(t *testing.T) { v, _ := curve.Scalar.SetBigInt(value) n := 64 // the range is [0, 2^64] - privateKey, err := testutils.GenerateKey() - require.Nil(t, err, "Error generating private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keyPair, err := eg.KeyGen(*privateKey, TestDenom) + keyPair, err := eg.KeyGen(*privateKey) require.Nil(t, err, "Error generating key pair") ciphertext, gamma, _ := eg.Encrypt(keyPair.PublicKey, value) @@ -162,11 +160,10 @@ func TestRangeProofs(t *testing.T) { value := big.NewInt(100) n := 64 // the range is [0, 2^64] - privateKey, err := testutils.GenerateKey() - require.Nil(t, err, "Error generating private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keyPair, err := eg.KeyGen(*privateKey, TestDenom) + keyPair, err := eg.KeyGen(*privateKey) require.Nil(t, err, "Error generating key pair") ciphertext, gamma, _ := eg.Encrypt(keyPair.PublicKey, value) @@ -193,11 +190,10 @@ func TestRangeProofsLargeN(t *testing.T) { value := big.NewInt(100) n := 128 // the range is [0, 2^128] - privateKey, err := testutils.GenerateKey() - require.Nil(t, err, "Error generating private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keyPair, err := eg.KeyGen(*privateKey, TestDenom) + keyPair, err := eg.KeyGen(*privateKey) require.Nil(t, err, "Error generating key pair") ciphertext, gamma, _ := eg.Encrypt(keyPair.PublicKey, value) @@ -227,11 +223,10 @@ func TestRangeProofsWithMarshaling(t *testing.T) { value := big.NewInt(100) n := 64 // the range is [0, 2^64] - privateKey, err := testutils.GenerateKey() - require.Nil(t, err, "Error generating private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keyPair, err := eg.KeyGen(*privateKey, TestDenom) + keyPair, err := eg.KeyGen(*privateKey) require.Nil(t, err, "Error generating key pair") ciphertext, gamma, _ := eg.Encrypt(keyPair.PublicKey, value) @@ -257,11 +252,10 @@ func TestRangeProofsWithMarshaling(t *testing.T) { } func TestRangeProofs_InvalidInput(t *testing.T) { - privateKey, err := testutils.GenerateKey() - require.Nil(t, err, "Error generating private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keyPair, err := eg.KeyGen(*privateKey, TestDenom) + keyPair, err := eg.KeyGen(*privateKey) require.Nil(t, err, "Error generating key pair") _, gamma, _ := eg.Encrypt(keyPair.PublicKey, big.NewInt(10)) @@ -284,10 +278,10 @@ func TestRangeProofs_InvalidInput(t *testing.T) { } func TestVerifyRangeProof_InvalidInput(t *testing.T) { - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() value := big.NewInt(10) - keyPair, _ := eg.KeyGen(*privateKey, TestDenom) + keyPair, _ := eg.KeyGen(*privateKey) ciphertext, gamma, _ := eg.Encrypt(keyPair.PublicKey, value) proof, err := NewRangeProof(64, value, gamma) @@ -329,11 +323,10 @@ func TestRangeProofVerifierReuse(t *testing.T) { value := big.NewInt(10) n := 128 // the range is [0, 2^128] - privateKey, err := testutils.GenerateKey() - require.Nil(t, err, "Error generating private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keyPair, err := eg.KeyGen(*privateKey, TestDenom) + keyPair, err := eg.KeyGen(*privateKey) require.Nil(t, err, "Error generating key pair") ciphertext, gamma, _ := eg.Encrypt(keyPair.PublicKey, value) diff --git a/pkg/zkproofs/zero_balance_test.go b/pkg/zkproofs/zero_balance_test.go index 4398002..fb1a333 100644 --- a/pkg/zkproofs/zero_balance_test.go +++ b/pkg/zkproofs/zero_balance_test.go @@ -42,12 +42,12 @@ func TestZeroBalanceProof(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // Setup keypair - privateKey, _ := testutils.GenerateKey() - altPrivateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() + altPrivateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keypair, _ := eg.KeyGen(*privateKey, TestDenom) - alternativeKeypair, _ := eg.KeyGen(*altPrivateKey, TestDenom) + keypair, _ := eg.KeyGen(*privateKey) + alternativeKeypair, _ := eg.KeyGen(*altPrivateKey) actualPublicKey := keypair.PublicKey if tt.useDifferentPubKey { @@ -75,10 +75,10 @@ func TestZeroBalanceProof(t *testing.T) { } func TestZeroBalanceProof_MarshalUnmarshalJSON(t *testing.T) { - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keypair, _ := eg.KeyGen(*privateKey, TestDenom) + keypair, _ := eg.KeyGen(*privateKey) ciphertext, _, _ := eg.Encrypt(keypair.PublicKey, big.NewInt(0)) original, err := NewZeroBalanceProof(keypair, ciphertext) @@ -100,11 +100,10 @@ func TestZeroBalanceProof_MarshalUnmarshalJSON(t *testing.T) { } func TestZeroBalanceProof_InvalidRandomness(t *testing.T) { - privateKey, err := testutils.GenerateKey() - require.NoError(t, err, "Failed to generate private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keypair, err := eg.KeyGen(*privateKey, TestDenom) + keypair, err := eg.KeyGen(*privateKey) require.NoError(t, err, "Failed to generate key pair") ciphertext, _, err := eg.Encrypt(keypair.PublicKey, big.NewInt(0)) @@ -127,11 +126,10 @@ func TestZeroBalanceProof_InvalidRandomness(t *testing.T) { } func TestZeroBalanceProof_ExtremelyLargeScalars(t *testing.T) { - privateKey, err := testutils.GenerateKey() - require.NoError(t, err, "Failed to generate private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keypair, err := eg.KeyGen(*privateKey, TestDenom) + keypair, err := eg.KeyGen(*privateKey) require.NoError(t, err, "Failed to generate key pair") ciphertext, _, err := eg.Encrypt(keypair.PublicKey, big.NewInt(0)) @@ -157,11 +155,10 @@ func TestZeroBalanceProof_ExtremelyLargeScalars(t *testing.T) { } func TestZeroBalanceProof_TamperedProof(t *testing.T) { - privateKey, err := testutils.GenerateKey() - require.NoError(t, err, "Failed to generate private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keypair, err := eg.KeyGen(*privateKey, TestDenom) + keypair, err := eg.KeyGen(*privateKey) require.NoError(t, err, "Failed to generate key pair") ciphertext, _, err := eg.Encrypt(keypair.PublicKey, big.NewInt(0)) @@ -203,11 +200,10 @@ func TestZeroBalanceProof_InvalidInput(t *testing.T) { require.Error(t, err, "Should return an error when ciphertext is nil") require.Contains(t, err.Error(), "keypair is invalid") - privateKey, err := testutils.GenerateKey() - require.NoError(t, err, "Failed to generate private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keypair, _ := eg.KeyGen(*privateKey, TestDenom) + keypair, _ := eg.KeyGen(*privateKey) _, err = NewZeroBalanceProof(&elgamal.KeyPair{PublicKey: keypair.PublicKey}, nil) require.Error(t, err, "Should return an error when ciphertext is nil") require.Contains(t, err.Error(), "keypair is invalid") @@ -231,11 +227,10 @@ func TestZeroBalanceProof_InvalidInput(t *testing.T) { } func TestVerifyZeroProof_InvalidInput(t *testing.T) { - privateKey, err := testutils.GenerateKey() - require.NoError(t, err, "Failed to generate private key") + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keypair, err := eg.KeyGen(*privateKey, TestDenom) + keypair, err := eg.KeyGen(*privateKey) require.NoError(t, err, "Failed to generate key pair") ciphertext, _, err := eg.Encrypt(keypair.PublicKey, big.NewInt(0)) @@ -298,10 +293,10 @@ func TestVerifyZeroProof_InvalidInput(t *testing.T) { func TestZeroBalanceProof_IdentityD(t *testing.T) { // Setup keypair - privateKey, _ := testutils.GenerateKey() + privateKey := testutils.GenerateKey() eg := elgamal.NewTwistedElgamal() - keypair, _ := eg.KeyGen(*privateKey, TestDenom) + keypair, _ := eg.KeyGen(*privateKey) ciphertext, _, err := eg.Encrypt(keypair.PublicKey, big.NewInt(100)) require.NoError(t, err, "Failed to encrypt amount")