Commit 03cf4408 authored by Anders Jensen Løvig's avatar Anders Jensen Løvig
Browse files

OGen for Elgamal

parent 2c872b29
......@@ -9,7 +9,6 @@ import (
)
var one = big.NewInt(1)
var two = big.NewInt(2)
type PublicKey struct {
P, Q, G, H *big.Int
......
package oblivious
import (
"crycomp/internal/blood/crypto/elgamal"
"crycomp/internal/blood/crypto/group"
"crypto/rand"
"io"
"math/big"
)
var one = big.NewInt(1)
var two = big.NewInt(2)
func OGenElgamel(random io.Reader, params *group.Params) (pub *elgamal.PublicKey, err error) {
tmp := new(big.Int).Sub(params.P, one)
// sample
r, err := rand.Int(random, tmp)
if err != nil {
return
}
s := r.Add(r, one)
pub = &elgamal.PublicKey{
P: params.P,
Q: params.Q,
G: params.G,
H: s.Exp(r, two, params.P),
}
return
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment