Esempio n. 1
0
File: dbl.go Progetto: 46bit/pnc
func main() {
	curve := ec.NewP256Curve()

	p := curve.G.Copy()

	// ----------------

	fmt.Println("Before:")
	p.Print()

	for i := 0; i < 10000; i++ {
		p = curve.Double(p)
	}

	fmt.Println("After:")
	p.Print()
}
Esempio n. 2
0
File: add.go Progetto: 46bit/pnc
func main() {
	curve := ec.NewP256Curve()

	p := curve.G.Copy()
	q := ec.NewPoint(dual_ec_drbg_curve_p256_qx, dual_ec_drbg_curve_p256_qy, 16)

	t := big.NewInt(0)
	t.SetString("05ABA71EB402603B7D24D9F921E49433A69AB3DB2D5A9910FF040FA906207587", 16)

	// ----------------

	fmt.Println("Before:")
	p.Print()

	for i := 0; i < 1931; i++ {
		p = curve.Add(p, q)
	}

	fmt.Println("After:")
	p.Print()
}
Esempio n. 3
0
func main() {
	// Generate pseudorandom bytes using Dual_EC_DRBG on NIST Curve-256.
	// NB: Never, ever use this generator. It is ridiculously slow, demonstrates bias
	// and for the provided values of Q is backdoored by the NSA.

	// The seed s is the value of S *after* seeding the OpenSSL implementation.
	// Any integer on the order of 2^256 will suffice.
	// @TODO: Have compatible seeding routines with OpenSSL.
	s := ec.NewBigInt("14611F02F7F34E6121433EFB0D71ECAC38F28BE4274B3DD784D2C1D4BE78DF89", 16)

	curve := ec.NewP256Curve()
	g := pnc.NewDualECDRBG(
		curve,
		ec.NewBigInt(dual_ec_drbg_curve_p256_qx, 16),
		ec.NewBigInt(dual_ec_drbg_curve_p256_qy, 16),
		s)

	for i := 0; i < 10; i++ {
		fmt.Printf("%x", g.Bytes(600))
	}
	fmt.Println()
}
Esempio n. 4
0
File: mul.go Progetto: 46bit/pnc
func main() {
	curve := ec.NewP256Curve()

	p := curve.G.Copy()

	t := big.NewInt(0)
	t.SetString("05ABA71EB402603B7D24D9F921E49433A69AB3DB2D5A9910FF040FA906207587", 16)

	// ----------------

	fmt.Println("Before:")
	p.Print()

	r := curve.ScalarMultiply(t, p)

	fmt.Println("After:")
	r.Print()

	fmt.Printf("Expected:\n- x = %X\n- y = %X\n- on curve: %t\n",
		ec.NewBigInt("7FDA41915769256A2D8F968BC9897849FC44C5CA64CF03E576EAF95E5FF9A799", 16),
		ec.NewBigInt("D7E013E76E4CEDCEB49F8C267164954F0D57C3FD077B0A81DF4DDA5AF4D5868D", 16),
		true)
}