-
Notifications
You must be signed in to change notification settings - Fork 8
/
keyssignatures.go
53 lines (40 loc) · 963 Bytes
/
keyssignatures.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package types
import (
"encoding/json"
)
// PublicKeyMPL is a public key
type PublicKeyMPL Bytes48
// G1Element is a public key
type G1Element PublicKeyMPL
// MarshalJSON custom hex marshaller
func (g G1Element) MarshalJSON() ([]byte, error) {
return json.Marshal(Bytes48(g))
}
// UnmarshalJSON custom hex unmarshaller
func (g *G1Element) UnmarshalJSON(data []byte) error {
b48 := Bytes48{}
err := json.Unmarshal(data, &b48)
if err != nil {
return err
}
*g = G1Element(b48)
return nil
}
// SignatureMPL is a signature
type SignatureMPL Bytes96
// G2Element is a signature
type G2Element SignatureMPL
// MarshalJSON custom hex marshaller
func (g G2Element) MarshalJSON() ([]byte, error) {
return json.Marshal(Bytes96(g))
}
// UnmarshalJSON custom hex unmarshaller
func (g *G2Element) UnmarshalJSON(data []byte) error {
b96 := Bytes96{}
err := json.Unmarshal(data, &b96)
if err != nil {
return err
}
*g = G2Element(b96)
return nil
}