File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,35 @@ func ParsePrivateKey(key string) (Key, error) {
7272 }, nil
7373}
7474
75+ // ParsePublicKey parses a public key generated using key.String().
76+ func ParsePublicKey (key string ) (Key , error ) {
77+ k , err := wgtypes .ParseKey (key )
78+ if err != nil {
79+ return Key {}, err
80+ }
81+
82+ return Key {
83+ k : k ,
84+ isPrivate : false ,
85+ }, nil
86+ }
87+
88+ // FromNoisePrivateKey converts a device.NoisePrivateKey to a Key.
89+ func FromNoisePrivateKey (k device.NoisePrivateKey ) Key {
90+ return Key {
91+ k : wgtypes .Key (k ),
92+ isPrivate : true ,
93+ }
94+ }
95+
96+ // FromNoisePublicKey converts a device.NoisePublicKey to a Key.
97+ func FromNoisePublicKey (k device.NoisePublicKey ) Key {
98+ return Key {
99+ k : wgtypes .Key (k ),
100+ isPrivate : false ,
101+ }
102+ }
103+
75104// IsZero returns true if the Key is the zero value.
76105func (k Key ) IsZero () bool {
77106 return k .k == wgtypes.Key {}
You can’t perform that action at this time.
0 commit comments