roll
암호문의 순환
Engine.roll(ciphertext, roll_key, shift, axis=None)- 암호문을 지정된 shift 만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다. 일반적으로 레벨을 소모하지 않습니다. 부트스트랩용으로 생성된 엔진이 아니면서 최대 레벨인 경우에만 레벨을 소모합니다.
- 인풋:
CiphertextRollKey- shift:
int - axis:
int, optional- 벡터 엔진에서는
None이어야 합니다. - 행렬 엔진에서는 순환할 축입니다:
0(batch),1(row),2(column).
- 벡터 엔진에서는
- 아웃풋:
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_ciphertext = engine.roll(ciphertext, roll_key, shift=1)
import numpy as np
from desilofhe import Engine
engine = Engine(form="matrix")
secret_key = engine.create_secret_key()
roll_key = engine.create_roll_key(secret_key)
message = np.arange(np.prod(engine.shape)).reshape(engine.shape)
ciphertext = engine.encrypt(message, secret_key)
batch_rolled = engine.roll(ciphertext, roll_key, shift=1, axis=0)
row_rolled = engine.roll(ciphertext, roll_key, shift=1, axis=1)
column_rolled = engine.roll(ciphertext, roll_key, shift=1, axis=2)
Engine.roll(ciphertext, fixed_roll_key)- 고정 순환 키의 이동량과 축에 따라 암호문을 순환시켜서 반환합니다. 일반적으로 레벨을 소모하지 않습니다. 부트스트랩용으로 생성된 엔진이 아니면서 최대 레벨인 경우에만 레벨을 소모합니다.
- 인풋:
CiphertextFixedRollKey
- 아웃풋:
Ciphertext
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
fixed_roll_key = engine.create_fixed_roll_key(secret_key, shift=1)
message = [1, 2, 3]
ciphertext = engine.encrypt(message, secret_key)
rolled_ciphertext = engine.roll(ciphertext, fixed_roll_key)
Engine.roll(ciphertext, shift, axis)- 행렬 엔진의 암호문을 키 없이 column 축으로 순환시켜서 반환합니다.
axis=2만 지원합니다.
- 인풋:
Ciphertext- shift:
int - axis:
int2(column)이어야 합니다.
- 아웃풋:
Ciphertext
Warning
- 벡터 엔진은 이 연산을 지원하지 않습니다.
import numpy as np
from desilofhe import Engine
engine = Engine(form="matrix")
secret_key = engine.create_secret_key()
message = np.arange(np.prod(engine.shape)).reshape(engine.shape)
ciphertext = engine.encrypt(message, secret_key)
column_rolled = engine.roll(ciphertext, shift=1, axis=2)
Engine.roll(ciphertext, bootstrap_key, shift, axis=None)- 부트스트랩 키에 포함된 고정 순환 키를 사용하여, 암호문을 지정된 shift 만큼 오른쪽으로 순환시켜서 반환합니다.
Engine(bootstrap=True)로 생성한 엔진에서만 사용할 수 있습니다.[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다.
- 인풋:
CiphertextBootstrapKey- shift:
int - axis:
None, optional
- 아웃풋:
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_ciphertext = engine.roll(ciphertext, bootstrap_key, shift=1)
Engine.roll(ciphertext, evaluation_key, shift, axis=None)- 연산 키에 포함된 순환 키를 사용하여, 암호문을 지정된 shift 만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다. 일반적으로 레벨을 소모하지 않습니다. 부트스트랩용으로 생성된 엔진이 아니면서 최대 레벨인 경우에만 레벨을 소모합니다.
- 인풋:
CiphertextEvaluationKey- shift:
int - axis:
None, optional
- 아웃풋:
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_ciphertext = engine.roll(ciphertext, evaluation_key, shift=1)
인코딩된 평문의 순환
Engine.roll(plaintext, shift, axis=None)- 인코딩된 평문을 지정된 shift 만큼 오른쪽으로 순환시켜서 반환합니다.
[1, 2, 3, 4]를 1만큼 순환시키면[4, 1, 2, 3]이 됩니다.
- 인풋:
Plaintext- shift:
int - axis:
None, optional
- 아웃풋:
Plaintext
Warning
- 행렬 엔진은 이 연산을 아직 지원하지 않습니다.