cryptofun/ecdsa/README.md
ecdsa/README.mdRaw
1## ECC ECDSA
2- https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm
3
4- [x] define ECDSA data structure
5- [x] ECDSA Sign
6- [x] ECDSA Verify signature
7
8
9#### Usage
10```go
11// define new elliptic curve
12ec := ecc.NewEC(big.NewInt(int64(1)), big.NewInt(int64(18)), big.NewInt(int64(19)))
13// define new point
14g := ecc.Point{big.NewInt(int64(7)), big.NewInt(int64(11))}
15
16// define new ECDSA system
17dsa, err := NewDSA(ec, g)
18if err!=nil {
19 fmt.Println(err)
20}
21
22// define privK&pubK over the elliptic curve
23privK := big.NewInt(int64(5))
24pubK, err := dsa.PubK(privK)
25if err!=nil {
26 fmt.Println(err)
27}
28
29// hash value to sign
30hashval := big.NewInt(int64(40))
31
32// define r
33r := big.NewInt(int64(11))
34
35// sign hashed value
36sig, err := dsa.Sign(hashval, privK, r)
37if err!=nil {
38 fmt.Println(err)
39}
40
41// verify signature
42verified, err := dsa.Verify(hashval, sig, pubK)
43if err!=nil {
44 fmt.Println(err)
45}
46if verified {
47 fmt.Println("signature correctly verified")
48}
49```