// +build generic32 package ec256 import ( "fmt" "math/big" "testing" "xdx.jelly/xgcl/gmath" ) // 窗口为8的预计算点 func TestGenCurvePrecompute8(t *testing.T) { table := make([]*big.Int, 0, 2*256) // for i = i[k], i[i] = 0 or 1 // table[i] is i[0] + i[1]*2^32 + i[2]*2^64 + ... + i[7]*2^{224} for i := 0; i < 256; i++ { k := new(big.Int) for j := 7; j >= 0; j-- { if (i>>j)&1 != 0 { k.Add(k, gmath.BigInt1) } k.Lsh(k, 32) } x, y := c256.ScalarBaseMult(k.Bytes()) table = append(table, x) table = append(table, y) } for _, x := range table { var out [c256Limbs]uint32 c256FromBig(&out, x) fmt.Printf("0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x\n", out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8], ) // fmt.Printf("&curvePoint{gfP{0x%x,0x%x,0x%x,0x%x},gfP{0x%x,0x%x,0x%x,0x%x},*newGFp(1),*newGFp(1)},\n", // x.x[0], x.x[1], x.x[2], x.x[3], // x.y[0], x.y[1], x.y[2], x.y[3]) } }