|
8 | 8 | from typing import Any, Callable, Optional, Sequence, Union, get_args, overload
|
9 | 9 |
|
10 | 10 | import numpy as np
|
11 |
| -from nada_dsl import (Input, Integer, Output, Party, PublicInteger, |
| 11 | +from nada_dsl import (Boolean, Input, Integer, Output, Party, PublicInteger, |
12 | 12 | PublicUnsignedInteger, SecretInteger,
|
13 | 13 | SecretUnsignedInteger, UnsignedInteger)
|
14 | 14 |
|
15 | 15 | from nada_algebra.context import UnsafeArithmeticSession
|
16 |
| -from nada_algebra.nada_typing import (NadaBoolean, NadaInteger, NadaRational, |
| 16 | +from nada_algebra.nada_typing import (NadaBoolean, NadaCleartextType, |
| 17 | + NadaInteger, NadaRational, |
17 | 18 | NadaUnsignedInteger)
|
18 | 19 | from nada_algebra.types import (Rational, SecretRational, get_log_scale,
|
19 | 20 | public_rational, rational, secret_rational)
|
@@ -738,6 +739,24 @@ def is_boolean(self) -> bool:
|
738 | 739 | """
|
739 | 740 | return self.dtype == NadaBoolean
|
740 | 741 |
|
| 742 | + @property |
| 743 | + def cleartext_nada_type(self) -> NadaCleartextType: |
| 744 | + """ |
| 745 | + Returns a clear-text Nada type compatible with the Nada array. |
| 746 | +
|
| 747 | + Returns: |
| 748 | + NadaCleartextType: Compatible cleartext type. |
| 749 | + """ |
| 750 | + if self.is_rational: |
| 751 | + return Rational |
| 752 | + if self.is_integer: |
| 753 | + return Integer |
| 754 | + if self.is_unsigned_integer: |
| 755 | + return UnsignedInteger |
| 756 | + if self.is_boolean: |
| 757 | + return Boolean |
| 758 | + raise TypeError(f"Array {self} is of unknown type {self.dtype}.") |
| 759 | + |
741 | 760 | def __str__(self) -> str:
|
742 | 761 | """
|
743 | 762 | String representation of the NadaArray.
|
|
0 commit comments