diff options
| author | Clawd <ai@clawd.bot> | 2026-02-19 20:53:27 -0800 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-02-19 20:53:27 -0800 |
| commit | aa8684e440c619cbff36bba1a9a96c9a503941ab (patch) | |
| tree | 762e7d3e606ddfbd80a78099ecae0a6bfd25a925 /main.go | |
| parent | e190cdb8fc96be0c571e3cbcc414e2feb7991ece (diff) | |
Add field_test.go, simplify main.go
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 29 |
1 files changed, 2 insertions, 27 deletions
| @@ -3,31 +3,6 @@ package main | |||
| 3 | import "fmt" | 3 | import "fmt" |
| 4 | 4 | ||
| 5 | func main() { | 5 | func main() { |
| 6 | fmt.Println("=== secp256k1 from scratch ===") | 6 | fmt.Println("secp256k1 from scratch") |
| 7 | fmt.Println() | 7 | fmt.Println("Run: go test -v") |
| 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 | } | 8 | } |
