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[FixedRollKey]
- 아웃풋:
list[Ciphertext]
Warning
- 행렬 엔진은 이 연산을 아직 지원하지 않습니다.
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, axis=None)- 암호문을 지정된 shifts 각각의 값만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다. 하나의 암호문을 여러 번 순환해야 하는 경우roll함수를 여러 번 호출하는 것에 비해 효율적입니다. 일반적으로 레벨을 소모하지 않습니다. 부트스트랩용으로 생성된 엔진이 아니면서 최대 레벨인 경우에만 레벨을 소모합니다.
- 인풋:
CiphertextRollKey- shifts:
list[int] - axis:
None, optional
- 아웃풋:
list[Ciphertext]
Warning
- 행렬 엔진은 이 연산을 아직 지원하지 않습니다.
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, axis=None)- 연산 키에 포함된 순환 키를 사용하여, 암호문을 지정된 shifts 각각의 값만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다. 하나의 암호문을 여러 번 순환해야 하는 경우roll함수를 여러 번 호출하는 것에 비해 효율적입니다. 일반적으로 레벨을 소모하지 않습니다. 부트스트랩용으로 생성된 엔진이 아니면서 최대 레벨인 경우에만 레벨을 소모합니다.
- 인풋:
CiphertextEvaluationKey- shifts:
list[int] - axis:
None, optional
- 아웃풋:
list[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])
부트스트랩 키를 통한 순환
Engine.roll_many(ciphertext, bootstrap_key, shifts)- 부트스트랩 키에 포함된 고정 순환 키를 사용하여, 암호문을 각각의 shift 만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다.Engine(bootstrap=True)로 생성한 엔진에서만 사용할 수 있습니다.
- 인풋:
CiphertextBootstrapKey- shifts:
list[int]
- 아웃풋:
list[Ciphertext]
Warning
- 행렬 엔진은 이 연산을 아직 지원하지 않습니다.
from desilofhe import Engine
engine = Engine(bootstrap=True)
secret_key = engine.create_secret_key()
bootstrap_key = engine.create_bootstrap_key(secret_key)
message = [1, 2, 3]
ciphertext = engine.encrypt(message, secret_key)
rolled_ciphertexts = engine.roll_many(ciphertext, bootstrap_key, shifts=[1, 2])