-
Notifications
You must be signed in to change notification settings - Fork 1
/
rsig_ser.go
43 lines (35 loc) · 1.01 KB
/
rsig_ser.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
package gotrax
// Deserialize will deserialize a ring signature or return failure
func (r *RingSignature) Deserialize(buf []byte) ([]byte, bool) {
var ok bool
if buf, r.C1, ok = DeserializeScalar(buf); !ok {
return nil, false
}
if buf, r.R1, ok = DeserializeScalar(buf); !ok {
return nil, false
}
if buf, r.C2, ok = DeserializeScalar(buf); !ok {
return nil, false
}
if buf, r.R2, ok = DeserializeScalar(buf); !ok {
return nil, false
}
if buf, r.C3, ok = DeserializeScalar(buf); !ok {
return nil, false
}
if buf, r.R3, ok = DeserializeScalar(buf); !ok {
return nil, false
}
return buf, true
}
// Serialize will return the serialization of the ring signature
func (r *RingSignature) Serialize() []byte {
var out []byte
out = append(out, SerializeScalar(r.C1)...)
out = append(out, SerializeScalar(r.R1)...)
out = append(out, SerializeScalar(r.C2)...)
out = append(out, SerializeScalar(r.R2)...)
out = append(out, SerializeScalar(r.C3)...)
out = append(out, SerializeScalar(r.R3)...)
return out
}