aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..9e19d35
--- /dev/null
+++ b/main.go
@@ -0,0 +1,33 @@
1package main
2
3import "fmt"
4
5func main() {
6 fmt.Println("=== secp256k1 from scratch ===")
7 fmt.Println()
8
9 // Test field arithmetic with small numbers first
10 fmt.Println("Testing field arithmetic:")
11
12 a := NewFieldElementFromInt64(7)
13 b := NewFieldElementFromInt64(5)
14
15 fmt.Printf("a = %d\n", 7)
16 fmt.Printf("b = %d\n", 5)
17 fmt.Printf("a + b = %s (should end in ...c)\n", a.Add(b).String())
18 fmt.Printf("a - b = %s (should end in ...2)\n", a.Sub(b).String())
19 fmt.Printf("a * b = %s (should end in ...23, which is 35)\n", a.Mul(b).String())
20
21 // Test division: 10 / 5 = 2
22 ten := NewFieldElementFromInt64(10)
23 five := NewFieldElementFromInt64(5)
24 fmt.Printf("10 / 5 = %s (should end in ...2)\n", ten.Div(five).String())
25
26 // Test inverse: 5 * inverse(5) should = 1
27 inv := five.Inverse()
28 product := five.Mul(inv)
29 fmt.Printf("5 * inverse(5) = %s (should end in ...1)\n", product.String())
30
31 fmt.Println()
32 fmt.Println("Field arithmetic works!")
33}