-
Notifications
You must be signed in to change notification settings - Fork 14
/
gotrax_append.go
42 lines (35 loc) · 1.27 KB
/
gotrax_append.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
package otr3
import "math/big"
// AppendShort will append the serialization of the given value to the byte array
// Data will be serialized big-endian
func AppendShort(l []byte, r uint16) []byte {
return append(l, SerializeShort(r)...)
}
// AppendWord will append the serialization of the given value to the byte array
// Data will be serialized big-endian
func AppendWord(l []byte, r uint32) []byte {
return append(l, SerializeWord(r)...)
}
// AppendLong will append the serialization of the given value to the byte array
// Data will be serialized big-endian
func AppendLong(l []byte, r uint64) []byte {
return append(l, SerializeLong(r)...)
}
// AppendData will append the serialization of the given value to the byte array
// Data will be serialized big-endian
func AppendData(l, r []byte) []byte {
return append(AppendWord(l, uint32(len(r))), r...)
}
// AppendMPI will append the serialization of the given value to the byte array
// Data will be serialized big-endian
func AppendMPI(l []byte, r *big.Int) []byte {
return AppendData(l, r.Bytes())
}
// AppendMPIs will append the serialization of the given values to the byte array
// Data will be serialized big-endian
func AppendMPIs(l []byte, r ...*big.Int) []byte {
for _, mpi := range r {
l = AppendMPI(l, mpi)
}
return l
}