ElGamal implementation
- Source:
Members
(inner) x
Re-derive public key y' = g ** x mod p Expect y == y'
Blinded exponentiation computes g**{r(p-1) + x} to compare to y
- Source:
Methods
(async, static) decrypt(c1, c2, p, x, randomPayload) → {Promise.<Uint8Array>}
ElGamal Encryption function
Parameters:
Name | Type | Description |
---|---|---|
c1 |
Uint8Array | |
c2 |
Uint8Array | |
p |
Uint8Array | |
x |
Uint8Array | |
randomPayload |
Uint8Array | Data to return on unpadding error, instead of throwing (needed for constant-time processing) |
- Source:
Throws:
-
on decryption error, unless
randomPayload
is given - Type
- Error
Returns:
Unpadded message.
- Type
- Promise.<Uint8Array>
(async, static) encrypt(data, p, g, y) → {Promise.<{c1: Uint8Array, c2: Uint8Array}>}
ElGamal Encryption function Note that in OpenPGP, the message needs to be padded with PKCS#1 (same as RSA)
Parameters:
Name | Type | Description |
---|---|---|
data |
Uint8Array | To be padded and encrypted |
p |
Uint8Array | |
g |
Uint8Array | |
y |
Uint8Array |
- Source:
Returns:
- Type
- Promise.<{c1: Uint8Array, c2: Uint8Array}>
(async, static) validateParams(p, g, y, x) → {Promise.<Boolean>}
Validate ElGamal parameters
Parameters:
Name | Type | Description |
---|---|---|
p |
Uint8Array | ElGamal prime |
g |
Uint8Array | ElGamal group generator |
y |
Uint8Array | ElGamal public key |
x |
Uint8Array | ElGamal private exponent |
- Source:
Returns:
Whether params are valid.
- Type
- Promise.<Boolean>