Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLargeCipher = errors.New("benaloh: cipher is larger than the public key size")
var ErrLargeMessage = errors.New("benaloh: message is larger than the public key size")
Functions ¶
This section is empty.
Types ¶
type PrivateKey ¶
PrivateKey represents a Benaloh private key.
func GenerateKey ¶
func GenerateKey(random io.Reader, bitsize int) (*PrivateKey, error)
GenerateKey generates the Benaloh private key of the given bit size.
func (*PrivateKey) Decrypt ¶
func (priv *PrivateKey) Decrypt(cipherText []byte) ([]byte, error)
Decrypt decrypts the passed cipher text. It returns an error if cipher text value is larger than modulus N of Public key. Moreover, this works by taking discrete log of a base x to recover original message m. It can only work, if R is small. Otherwise, message can be recovered using Baby-step giant-step algorithm in case of large value of R.
type PublicKey ¶
PublicKey represents Benaloh public key.
func (*PublicKey) Encrypt ¶
Encrypt encrypts a plain text represented as a byte array. It returns an error if plain text value is larger than R value of Public key.
func (*PublicKey) HommorphicEncMultiple ¶
HommorphicEncMultiple performs homomorphic operation over two chiphers. Benaloh has additive homomorphic property, so resultant cipher contains the sum of multiple numbers.