FHERMA
L2 · OPERATIONMEASURED

Encrypted Shift Left

encrypted-shl · spec v0.1.0 · 0 implementations · 6 runners

Create implementationSpecification

DESCRIPTION

Computes x << n, that is x · 2ⁿ, where both the value and the shift amount are encrypted.

A public shift is a multiplication by a constant. An encrypted shift is not: the multiplier itself has to be derived from ciphertext, so a realization builds 2ⁿ homomorphically — through a selection over the possible shift amounts, or by exponentiating in the encrypted domain.

The cookbook realization uses bootstrapping, which is a fair indication of the depth this costs.

INTERFACE

encrypted_shl(
  in  ct     : Ciphertext  // the encrypted first operand
  in  ct_n   : Ciphertext  // the encrypted shift amount
  out ct     : Ciphertext  // the encrypted result of the opcode
  ...               // anything else the realization needs — keys, context, encoding — is its own concern
)

PARAMETER SCHEMA

NAMETYPERANGE
word_maxinteger255 – 2^32
target_precisionnumber0.5 – 1
max_shiftinteger1 – 256

The schema belongs to the kernel. Each implementation declares which part of it it supports.

CORRECTNESS

01The result equals x multiplied by two to the power n, for every admissible pair.
02Shifting by zero returns the input unchanged.
03Overflow past the declared word size follows the EVM rule rather than growing without bound.
04The result matches the EVM definition of the opcode exactly, including its behaviour at the boundaries.

An opcode is exact by definition. Where the scheme is approximate, the precision threshold is what stands in for exactness, and it has to hold at every integer in range.

SECURITY PROPERTIES

Operands and result stay encrypted throughout. Nothing about the values may be observable through timing or control flow, which rules out any realization that branches on a decrypted intermediate.

ASSUMPTIONS

Operands are integers held exactly at the point of encryption.

REFERENCES

Encrypted Shift Left · FHERMA