325
func TestP256BaseMult(t *testing.T) {
327
p256Generic := p256.Params()
329
scalars := make([]*big.Int, 0, len(p224BaseMultTests)+1)
330
for _, e := range p224BaseMultTests {
331
k, _ := new(big.Int).SetString(e.k, 10)
332
scalars = append(scalars, k)
334
k := new(big.Int).SetInt64(1)
336
scalars = append(scalars, k)
338
for i, k := range scalars {
339
x, y := p256.ScalarBaseMult(k.Bytes())
340
x2, y2 := p256Generic.ScalarBaseMult(k.Bytes())
341
if x.Cmp(x2) != 0 || y.Cmp(y2) != 0 {
342
t.Errorf("#%d: got (%x, %x), want (%x, %x)", i, x, y, x2, y2)
345
if testing.Short() && i > 5 {
351
func TestP256Mult(t *testing.T) {
353
p256Generic := p256.Params()
355
for i, e := range p224BaseMultTests {
356
x, _ := new(big.Int).SetString(e.x, 16)
357
y, _ := new(big.Int).SetString(e.y, 16)
358
k, _ := new(big.Int).SetString(e.k, 10)
360
xx, yy := p256.ScalarMult(x, y, k.Bytes())
361
xx2, yy2 := p256Generic.ScalarMult(x, y, k.Bytes())
362
if xx.Cmp(xx2) != 0 || yy.Cmp(yy2) != 0 {
363
t.Errorf("#%d: got (%x, %x), want (%x, %x)", i, xx, yy, xx2, yy2)
365
if testing.Short() && i > 5 {
325
371
func TestInfinity(t *testing.T) {
326
372
tests := []struct {
420
func BenchmarkBaseMultP256(b *testing.B) {
423
e := p224BaseMultTests[25]
424
k, _ := new(big.Int).SetString(e.k, 10)
426
for i := 0; i < b.N; i++ {
427
p256.ScalarBaseMult(k.Bytes())
374
431
func TestMarshal(t *testing.T) {
376
433
_, x, y, err := GenerateKey(p224, rand.Reader)