@@ -5,7 +5,7 @@ using MODP groups as defined in [RFC3526](https://datatracker.ietf.org/doc/html/
55
66Example:
77
8- ``` Go
8+ ``` go
99import (
1010 " fmt"
1111 " reflect"
@@ -19,11 +19,51 @@ func main() {
1919 aliceSecret := alice.ComputeSecret (bob.PublicKey )
2020 bobSecret := bob.ComputeSecret (alice.PublicKey )
2121
22- fmt.Println (reflect.DeepEqual (aliceSecret, bobSecret))
22+ fmt.Println (reflect.DeepEqual (aliceSecret, bobSecret)) // true
2323}
2424```
2525
2626## Notes
2727
28- 1 . You must use the same MODP group on both sides, or else you
29- end up with non-matching keys. Group #14 is used by default.
28+ You must use the same MODP group on both sides, or else you
29+ end up with non-matching keys. Group #14 is used by default. You
30+ can use different group from available (5, 14, 15, 16, 17, 18).
31+ Example using other group:
32+
33+ ``` go
34+ import (
35+ " fmt"
36+ " reflect"
37+ " github.com/WolframAlph/dh"
38+ )
39+
40+ func main () {
41+ modpGroup := 16
42+ alice := dh.New (modpGroup)
43+ bob := dh.New (modpGroup)
44+
45+ aliceSecret := alice.ComputeSecret (bob.PublicKey )
46+ bobSecret := bob.ComputeSecret (alice.PublicKey )
47+
48+ fmt.Println (reflect.DeepEqual (aliceSecret, bobSecret)) // true
49+ }
50+ ```
51+
52+ Example using different groups:
53+ ``` go
54+ import (
55+ " fmt"
56+ " reflect"
57+ " github.com/WolframAlph/dh"
58+ )
59+
60+ func main () {
61+ alice := dh.New (15 )
62+ bob := dh.New (18 )
63+
64+ aliceSecret := alice.ComputeSecret (bob.PublicKey )
65+ bobSecret := bob.ComputeSecret (alice.PublicKey )
66+
67+ fmt.Println (reflect.DeepEqual (aliceSecret, bobSecret)) // false
68+ }
69+ ```
0 commit comments