// Create a new PrivateKey based on a random element on the field of a curve. func NewKeyFromInt(c *bitelliptic.BitCurve, k *big.Int) *PrivateKey { priv := new(PrivateKey) priv.PublicKey.BitCurve = c priv.D = k priv.PublicKey.X, priv.PublicKey.Y = c.ScalarBaseMult(k.Bytes()) return priv }
func testKeyGeneration(t *testing.T, c *bitelliptic.BitCurve, tag string) { priv, err := GenerateKey(c, rand.Reader) if err != nil { t.Errorf("%s: error: %s", tag, err) return } if !c.IsOnCurve(priv.PublicKey.X, priv.PublicKey.Y) { t.Errorf("%s: public key invalid: %s", tag, err) } }