roll_many
고정 순환 키들을 통한 순환
Engine.roll_many(ciphertext, fixed_roll_keys)- 암호문을 고정 순환 키들 각각의 지정된 shift 만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다. 하나의 암호문을 여러번 순환해야하는 경우roll함수를 여러번 호출하는 것에 비해 효율적입니다. 일반적으로 레벨을 소모하지 않습니다. 부트스트랩용으로 생성된 엔진이 아니면서 최대 레벨인 경우에만 레벨을 소모합니다.
- 인풋:
- Ciphertext
- fixed_roll_keys: list of FixedRollKey
- 아웃풋:
- list of Ciphertext
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
fixed_roll_key_1 = engine.create_fixed_roll_key(secret_key, shift=1)
fixed_roll_key_2 = engine.create_fixed_roll_key(secret_key, shift=2)
message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
fixed_roll_keys = [fixed_roll_key_1, fixed_roll_key_2]
rolled_ciphertexts = engine.roll_many(ciphertext, fixed_roll_keys)
순환 키를 통한 순환
Engine.roll_many(ciphertext, roll_key, shifts)- 암호문을 지정된 shifts 각각의 값만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다. 하나의 암호문을 여러번 순환해야하는 경우roll함수를 여러번 호출하는 것에 비해 효율적입니다. 일반적으로 레벨을 소모하지 않습니다. 부트스트랩용으로 생성된 엔진이 아니면서 최대 레벨인 경우에만 레벨을 소모합니다.
- 인풋:
- Ciphertext
- RollKey
- shifts: list of int
- 아웃풋:
- list of Ciphertext
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
roll_key = engine.create_roll_key(secret_key)
message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
rolled_ciphertexts = engine.roll_many(ciphertext, roll_key, shifts=[1, 2])
연산 키를 통한 순환
Engine.roll_many(ciphertext, evaluation_key, shifts)- 연산 키에 포함된 순환 키를 사용하여, 암호문을 지정된 shifts 각각의 값만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다. 하나의 암호문을 여러번 순환해야하는 경우roll함수를 여러번 호출하는 것에 비해 효율적입니다. 일반적으로 레벨을 소모하지 않습니다. 부트스트랩용으로 생성된 엔진이 아니면서 최대 레벨인 경우에만 레벨을 소모합니다.
- 인풋:
- Ciphertext
- EvaluationKey
- shifts: list of int
- 아웃풋:
- list of Ciphertext
Warning
- 행렬 엔진은 이 연산을 아직 지원하지 않습니다.
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
evaluation_key = engine.create_evaluation_key(secret_key)
message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
rolled_ciphertexts = engine.roll_many(ciphertext, evaluation_key, shifts=[1, 2])