forked from Equim-chan/vanity-monero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapper.go
45 lines (34 loc) · 962 Bytes
/
wrapper.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
package vanity
import (
"unsafe"
"github.com/paxos-bankchain/moneroutil"
"golang.org/x/crypto/sha3"
)
func pointAdd(dst, a, b *[32]byte) {
moneroutil.AddKeys((*moneroutil.Key)(dst), (*moneroutil.Key)(a), (*moneroutil.Key)(b))
}
func scAdd(dst, a, b *[32]byte) {
moneroutil.ScAdd((*moneroutil.Key)(dst), (*moneroutil.Key)(a), (*moneroutil.Key)(b))
}
func scReduce32(b *[32]byte) {
moneroutil.ScReduce32((*moneroutil.Key)(b))
}
func keccak256(data ...[]byte) *[32]byte {
h := sha3.NewLegacyKeccak256()
for _, v := range data {
h.Write(v)
}
sum := h.Sum(nil)
sum32 := (*[32]byte)(unsafe.Pointer(&sum[0]))
return sum32
}
func encodeBase58(data ...[]byte) string {
return moneroutil.EncodeMoneroBase58(data...)
}
func publicKeyFromPrivateKey(priv *[32]byte) *[32]byte {
pub := new([32]byte)
p := new(moneroutil.ExtendedGroupElement)
moneroutil.GeScalarMultBase(p, (*moneroutil.Key)(priv))
p.ToBytes((*moneroutil.Key)(pub))
return pub
}