Sha256: 7359c01cd5cadec5249dbc08b90093a8ce0a832f8b3e48d885617d8a11494073
Contents?: true
Size: 648 Bytes
Versions: 177
Compression:
Stored size: 648 Bytes
Contents
package diffiehellman import ( "math/big" "math/rand" "time" ) const testVersion = 1 var r = rand.New(rand.NewSource(time.Now().Unix())) var two = big.NewInt(2) func PrivateKey(p *big.Int) *big.Int { private := new(big.Int).Sub(p, two) return private.Add(two, private.Rand(r, private)) } func PublicKey(private, p *big.Int, g int64) *big.Int { return new(big.Int).Exp(big.NewInt(g), private, p) } func NewPair(p *big.Int, g int64) (private, public *big.Int) { private = PrivateKey(p) return private, PublicKey(private, p, g) } func SecretKey(private1, public2, p *big.Int) *big.Int { return new(big.Int).Exp(public2, private1, p) }
Version data entries
177 entries across 177 versions & 1 rubygems