Commit 82926b7b authored by luxq's avatar luxq

update

parent c2a2b1a0
Pipeline #517 canceled with stages
[server]
address = "0.0.0.0:9900"
privatekey = 0x0aa528c00748fd3fc37f5cb5f995f3da9c820df02aef5cb7786c8ea54abb0950
privatekey = 0aa528c00748fd3fc37f5cb5f995f3da9c820df02aef5cb7786c8ea54abb0950
[log]
level = info
file = service.log
\ No newline at end of file
file = service.log
......@@ -8,12 +8,12 @@ import (
"gitlab.com/hashrs/randomservice/common"
)
func RandomService(account []byte, pk string) (map[string]interface{},error) {
r,err := rand.Prime(rand.Reader, 128)
func RandomService(account []byte, pk string) (map[string]interface{}, error) {
r, err := rand.Prime(rand.Reader, 128)
if err != nil {
return nil, errors.New("generate prime failed")
}
data := common.BytesCombine(account,r.Bytes())
data := common.BytesCombine(account, r.Bytes())
sig, err := common.Sign(pk, data)
if err != nil {
return nil, errors.New(fmt.Sprintf("sign failed (%s)", err))
......@@ -21,7 +21,7 @@ func RandomService(account []byte, pk string) (map[string]interface{},error) {
var res = make(map[string]interface{})
res["rand"] = r.Text(16)
res["signature"] = hex.EncodeToString(sig)
res["signature"] = "0x" + hex.EncodeToString(sig)
return res, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment