Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type compatibility issue with if_else #68

Open
manel1874 opened this issue Aug 30, 2024 · 0 comments
Open

Type compatibility issue with if_else #68

manel1874 opened this issue Aug 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@manel1874
Copy link
Member

Bug description

There is a type compatibility issue with if_else depending on the origin of the boolean used. Consider b.if_else(a, c). If b is derived from a comparison between nada dsl base types (Integer, SecretInteger, PublicInteger, etc) and a and c are rational types, the operation b.if_else(a, c) throws the following error:

     raise TypeError(f"Invalid operation: {self}.IfElse({arg_0}, {arg_1})")
TypeError: Invalid operation: SecretBoolean(inner=<nada_dsl.operations.GreaterThan object at 0x7f8df2fd18d0>).IfElse(<nada_numpy.types.SecretRational object at 0x7f8df2fd1480>, <nada_numpy.types.SecretRational object at 0x7f8df2fd1600>)

Desired behaviour: SecretBoolean should be used independently from how it was generated.

How to reproduce

In the program below, option 1 throws the above error when running nada build. Option 2 works fine.

from nada_dsl import Output, SecretInteger, Input
import nada_numpy as na

def nada_main():

    parties = na.parties(3)

    a = na.secret_rational("A", parties[0])
    b = na.secret_rational("B", parties[1])
    c = SecretInteger(Input("C", parties[0]))
    
    # Option 1: throws the above error
    out_0 = (c > Integer(1)).if_else(a, b)
    # Option 2
    # out_0 = (a > b).if_else(a, b)

    return [Output(out_0.value, "my_output_0", parties[0])]
@manel1874 manel1874 added the bug Something isn't working label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant