A public-key encryption device wherein a second dimension ( m) of a second public-key matrix (u) is configurable during an encryption phase, the public-key encryption device comprising - a communication interface configured to communicate with a private-key decryption device, - a processor configured to - obtain a first public-key matrix (b) associated with the private-key decryption device, - obtain a key size for the transmission key, - generate a transmission key according to said key size, - determine a matrix size for a second private-key matrix (s) to accommodate masking of the transmission key of said key size by selecting a value of a second dimension ( m) of the second private-key matrix (s) accordingly, the second dimension ( m) of the second private-key matrix (s) being equal to the second dimension ( m) of the second public-key matrix (u), - generate the second private-key matrix (s) according to the matrix size, and compute the second public-key matrix (u) from the second private-key matrix (s), - compute a second raw shared key (k ∗) from the second private-key matrix (s) and the first public-key matrix (b), computing the second raw shared key comprising a matrix multiplication between the second private-key matrix (s) and the first public-key matrix (b), - mask the transmission key with at least part of the second raw shared key, - transfer an indication of the key size and/or matrix size, the second public-key matrix (u), and the masked transmission key (c) to the private-key decryption device. - a communication interface configured to communicate with a private-key decryption device, - a processor configured to - obtain a first public-key matrix (b) associated with the private-key decryption device, - obtain a key size for the transmission key, - generate a transmission key according to said key size, - determine a matrix size for a second private-key matrix (s) to accommodate masking of the transmission key of said key size by selecting a value of a second dimension ( m) of the second private-key matrix (s) accordingly, the second dimension ( m) of the second private-key matrix (s) being equal to the second dimension ( m) of the second public-key matrix (u), - generate the second private-key matrix (s) according to the matrix size, and compute the second public-key matrix (u) from the second private-key matrix (s), - compute a second raw shared key (k ∗) from the second private-key matrix (s) and the first public-key matrix (b), computing the second raw shared key comprising a matrix multiplication between the second private-key matrix (s) and the first public-key matrix (b), - mask the transmission key with at least part of the second raw shared key, - transfer an indication of the key size and/or matrix size, the second public-key matrix (u), and the masked transmission key (c) to the private-key decryption device. - obtain a first public-key matrix (b) associated with the private-key decryption device, - obtain a key size for the transmission key, - generate a transmission key according to said key size, - determine a matrix size for a second private-key matrix (s) to accommodate masking of the transmission key of said key size by selecting a value of a second dimension ( m) of the second private-key matrix (s) accordingly, the second dimension ( m) of the second private-key matrix (s) being equal to the second dimension ( m) of the second public-key matrix (u), - generate the second private-key matrix (s) according to the matrix size, and compute the second public-key matrix (u) from the second private-key matrix (s), - compute a second raw shared key (k ∗) from the second private-key matrix (s) and the first public-key matrix (b), computing the second raw shared key comprising a matrix multiplication between the second private-key matrix (s) and the first public-key matrix (b), - mask the transmission key with at least part of the second raw shared key, - transfer an indication of the key size and/or matrix size, the second public-key matrix (u), and the masked transmission key (c) to the private-key decryption device.