Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions zk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"math/big"

"github.com/ava-labs/EncryptedERC/pkg/circuits"
"github.com/ava-labs/EncryptedERC/pkg/utils"

"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark/backend/groth16"
Expand Down Expand Up @@ -102,7 +101,6 @@ func TestRegistration() {

func TestTransfer() {

utils.TestTransfer()
// Generate a proof for the registration circuit

// assignment := circuits.TransferCircuit{
Expand Down
47 changes: 14 additions & 33 deletions zk/pkg/poseidon/poseidon_decryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func poseidonDecrypt(
nonce frontend.Variable,
cipherText []frontend.Variable,
) []frontend.Variable {
l := decryptedLength
length := decryptedLength
for decryptedLength%3 != 0 {
decryptedLength += 1
}
Expand All @@ -26,7 +26,7 @@ func poseidonDecrypt(

strategies[0] = PoseidonEx(
api,
[]frontend.Variable{encryptionKey[0], encryptionKey[1], api.Add(nonce, api.Mul(l, two128))},
[]frontend.Variable{encryptionKey[0], encryptionKey[1], api.Add(nonce, api.Mul(length, two128))},
0,
4,
)
Expand All @@ -49,10 +49,21 @@ func poseidonDecrypt(
)
}

ZERO := frontend.Variable(0)

if length%3 != 0 {
if length%3 == 2 {
api.AssertIsEqual(out[length-1], ZERO)
} else if length%3 == 1 {
api.AssertIsEqual(out[length-1], ZERO)
api.AssertIsEqual(out[length-2], ZERO)
}
}

// Check the last ciphertext element
api.AssertIsEqual(cipherText[decryptedLength], strategies[n][1])

return out[:l]
return out[:length]
}

// implements poseidon decryption with 1 decrypted element
Expand All @@ -64,33 +75,3 @@ func PoseidonDecryptSingle(
) []frontend.Variable {
return poseidonDecrypt(api, 1, encryptionKey, nonce, cipherText[:])
}

// implements poseidon decryption with 2 decrypted elements
func PoseidonDecrypt_2(
api frontend.API,
encryptionKey [2]frontend.Variable,
nonce frontend.Variable,
cipherText [4]frontend.Variable,
) []frontend.Variable {
return poseidonDecrypt(api, 2, encryptionKey, nonce, cipherText[:])
}

// implements poseidon decryption with 3 decrypted elements
func PoseidonDecrypt_3(
api frontend.API,
encryptionKey [2]frontend.Variable,
nonce frontend.Variable,
cipherText [4]frontend.Variable,
) []frontend.Variable {
return poseidonDecrypt(api, 3, encryptionKey, nonce, cipherText[:])
}

// implements poseidon decryption with 4 decrypted elements
func PoseidonDecrypt_4(
api frontend.API,
encryptionKey [2]frontend.Variable,
nonce frontend.Variable,
cipherText [7]frontend.Variable,
) []frontend.Variable {
return poseidonDecrypt(api, 4, encryptionKey, nonce, cipherText[:])
}
168 changes: 0 additions & 168 deletions zk/pkg/utils/inputs.go

This file was deleted.

Loading