This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
moneroutil/internal_test.go

33 lines
671 B
Go
Raw Permalink Normal View History

2017-05-05 03:11:50 +00:00
package moneroutil
import (
"encoding/hex"
)
2017-05-14 00:36:32 +00:00
func HexToKey(h string) (result Key) {
byteSlice, _ := hex.DecodeString(h)
copy(result[:], byteSlice)
return
}
func HexToHash(h string) (result Hash) {
2017-05-05 03:11:50 +00:00
byteSlice, _ := hex.DecodeString(h)
copy(result[:], byteSlice)
return
}
2017-05-25 21:04:59 +00:00
// RandomPubKey takes a random scalar, interprets it as a point on the curve
// and then multiplies by 8 to make it a point in the Group
func RandomPubKey() (result *Key) {
result = new(Key)
p3 := new(ExtendedGroupElement)
var p1 ProjectiveGroupElement
var p2 CompletedGroupElement
h := RandomScalar()
p1.FromBytes(h)
GeMul8(&p2, &p1)
p2.ToExtended(p3)
p3.ToBytes(result)
return
}