Documentation
¶
Index ¶
- func KeyGen(pBits int, qBits int, t int, n int) (PublicKey, PrivateKey, []PrivateKeyShare, error)
- func RandomBits(bits int) ([]byte, error)
- func Recover(pub PublicKey, decryptionShares []DecryptionShare, ctxt Ciphertext) ([]byte, error)
- type Ciphertext
- type DecryptionShare
- type PrivateKey
- type PrivateKeyShare
- type PublicKey
- type SchnorrGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyGen ¶
func KeyGen(pBits int, qBits int, t int, n int) (PublicKey, PrivateKey, []PrivateKeyShare, error)
KeyGen implements key generation for a distributed ElGamal cryptosystem. It is to be executed by a trusted dealer, who can then send out the individual key shares.
Secret sharing is based on polynomials over a finite field.
Parameters: - pBits: Bit length of modulus p of multiplicative group of integers modulo p - qBits: Bit length of prime order of subgroup G over which ElGamal operates - t: Number of secret shares which should be able to reconstruct private key - n: Number of total secret shares to generate
func RandomBits ¶
RandomBits returns bits random bits suitable for cryptographic usage.
Bits must be > 2. If bits is not a multiple of 8, the leading bits of the first byte (at index 0) will be forced to 0.
It is also ensured that the two most significant bit are 1. This costs two bits of randomness, but helps with multiplying such numbers together. As such it is not suitable for use with low bit counts.
func Recover ¶
func Recover(pub PublicKey, decryptionShares []DecryptionShare, ctxt Ciphertext) ([]byte, error)
Recover decrypts a ciphertext using t decryption shares.
Types ¶
type Ciphertext ¶
Ciphertext represents a ciphertext of the hashed ElGamal cryptosystem.
type DecryptionShare ¶
type DecryptionShare secretshare.Share
DecryptionShare represents a single party's decryption share.
func Dec ¶
func Dec(pub PublicKey, keyShare PrivateKeyShare, ctxt Ciphertext) (DecryptionShare, error)
Dec creates a single decryption share of a ciphertext based on the passed share of the private key.
t of these can be passed to Recover() to decrypt the ciphertext.
type PrivateKey ¶
PrivateKey represents a private key of the ElGamal cryptosystem.
type PrivateKeyShare ¶
type PrivateKeyShare secretshare.Share
PrivateKeyShare represents a private key share of the distributed ElGamal cryptosystem.
type PublicKey ¶
type PublicKey struct { SchnorrGroup // Public key y = g^x mod p Y *big.Int }
PublicKey represents a public key of the ElGamal cryptosystem.
type SchnorrGroup ¶
type SchnorrGroup struct { // Prime modulus of multiplicative group of integers modulo p, (Z/pZ)* P *big.Int // Prime order of subgroup G of (Z/pZ)* Q *big.Int // Generator of subgroup G G *big.Int }
SchnorrGroup represents a q-order subgroup of the multiplicative group of integers modulo p.
func GenerateSchnorrGroup ¶
func GenerateSchnorrGroup(pBits int, qBits int) (SchnorrGroup, error)
GenerateSchnorrGroup generates a Schnorr subgroup of prime order Q, with q of length qBits, within the multiplicative group of integers modulo P, with p of length pBits.
qBits must be strictly less than pBits, otherwise an error is returned. An error may also be returned if sourcing of cryptographically secure randomness fails.