Approval program's length

I’m writing a Smart Contract in PyTeal, so an approval program and a clear program.
After I added some functions, I got this error: invalid : approval program too long. max len 1024 bytes, that let me think approval program couldn’t be longer. For me that’s a problem because I have to add so many lines of code.
Is there a solution to avoid this problem?

EDIT: to be clearer: my code is in approval_program function and I defined some functions out of approval_program.
In approval_program I call these function that I defined out of it.

Situation is even worse: application “gas” cost can be only 700 unit, in contract with passive contract “gas” of 20000.

Separate logic as far as possible: for state manipulation: app, for asset sending logic: contract. And the contract can be enabled/disabled by the app, and vice versa, using transaction groups. See the following great article: AlgoRealm, a NFT Royalty Game | Algorand Developer Portal

What do you mean with

?

I’m not very practical with contracts and apps in this platform.
I’m using a program like this: PyTeal Examples — PyTeal documentation, so the only thing I’m using is an application defined by approval program. I can’t understand the difference between application and contract.

The real question is: my approval_program currently is 30KB and I have to write so many lines more. Is there a way to implement it in-chain? Or Algorand don’t support complex logics like this?

Please try to read the artictle first I referred to.
Yes, there is a way to make applications cooperate, by sharing variables, buit I haven’t tried that yet.
Now is the time to make a framework, to make your example working.
Btw, how could you write 30 K worth of rules? (in TEAL, I think) What kind of rules are that? I am courious…

Actually my work is bachelor’s degree project, in which I try to implement an authentication system, based on biometrics, in-chain. So I tried to manage negative or float values, to avoid using of loops (repeating body n times) and so on.
My logic is (I think) too complex to run in-chain (this is what I want discover).

How are you planning to keep the biometrics secret and to prevent a user to re-use submitted biometrics for authentication?

Note that everything on-chain is completely public to everybody.
In particular, if a user submits their biometrics to a smart contract, they will be displayed to all users.
You might be able to use SNARK / zero-knowledge for that purpose but current limitations on TEAL do not allow for verification of a SNARK.

I know everything involved in smart contract is public, but I don’t pass the biometrics in clear, so I don’t think there is some problem.
The real problem is to know if it is possible to develop a complex logic using smart contract, considering all these problem.

I noticed one thing: my compiled file with the approval program is 1 KB dimension until I don’t add this call:
x = calculate_and_check_negative5(negative_t, t, h)
that referred to this:

def calculate_and_check_negative5(negative: Expr, a: Expr, b: Expr) -> TealType.uint64:
    return If (Eq(negative, Int(1)), a+b, Abs_diff(a, b))

and abs_diff(a, b) (that I call other times in approval_program) is:

def Abs_diff(a: Expr, b: Expr) -> TealType.uint64:
    return If (Lt(a, b), b-a, a-b)

When I add this call, file’s dimension increases from 1 KB to 21 KB, generating the length error.
Any tips?

No tips, only guesses. If negative_t, t, h is very complex, then this may happen. Please check the generated TEAL code. If possible, try to simplify.

If nothing helps, please send me the .py files and the script to compile them in email.

I use negative_t, t and h in other function call too, so I don’t think these can be a real problem.

If for you is ok, I can send you the whole project, because I split functions in different files.

Go ahead, and send it, please.

Where can I get the email?

Click on my icon (“Maugli”), then press the “Message” button, and then upload the files.