Parameter compatibility with restrictions
Keyset restriction
@fhe.module()
class Big:
@fhe.function({"x": "encrypted"})
def inc(x):
return (x + 1) % 200
big_inputset = [np.random.randint(1, 200, size=()) for _ in range(100)]
big_module = Big.compile(
{"inc": big_inputset},
)
big_keyset_info = big_module.keys.specs.program_info.get_keyset_info()
big_module.keygen()
# We get the restriction from the existing keyset
restriction = big_keyset_info.get_restriction()
@fhe.module()
class Small:
@fhe.function({"x": "encrypted"})
def inc(x):
return (x + 1) % 20
small_inputset = [np.random.randint(1, 20, size=()) for _ in range(100)]
small_module = Small.compile(
{"inc": small_inputset},
# We pass the keyset restriction as an extra compilation option
keyset_restriction=restriction
)
restricted_keyset_info = restricted_module.keys.specs.program_info.get_keyset_info()
assert big_keyset_info == restricted_keyset_info
small_module.keys = big_module.keys
x = 5
x_enc = small_module.inc.encrypt(x)Ranges restriction
Last updated
Was this helpful?