mirror of https://github.com/status-im/go-waku.git
fix: authcode padding and add String to messagenametag
This commit is contained in:
parent
5740a6d571
commit
ad33eabe39
|
@ -349,7 +349,7 @@ func (hs *Handshake) Authcode() (string, error) {
|
||||||
bn.SetBytes(output0)
|
bn.SetBytes(output0)
|
||||||
code := new(big.Int)
|
code := new(big.Int)
|
||||||
code.Mod(bn, big.NewInt(100_000_000))
|
code.Mod(bn, big.NewInt(100_000_000))
|
||||||
return fmt.Sprintf("'%8s'", code.String()), nil
|
return fmt.Sprintf("'%08s'", code.String()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handshake) messageNametagSecrets() (nms1 []byte, nms2 []byte, err error) {
|
func (hs *Handshake) messageNametagSecrets() (nms1 []byte, nms2 []byte, err error) {
|
||||||
|
|
|
@ -4,10 +4,11 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MessageNametag = [MessageNametagLength]byte
|
type MessageNametag [MessageNametagLength]byte
|
||||||
|
|
||||||
const MessageNametagLength = 16
|
const MessageNametagLength = 16
|
||||||
const MessageNametagBufferSize = 50
|
const MessageNametagBufferSize = 50
|
||||||
|
@ -24,6 +25,10 @@ func BytesToMessageNametag(input []byte) MessageNametag {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t MessageNametag) String() string {
|
||||||
|
return hex.EncodeToString(t[:])
|
||||||
|
}
|
||||||
|
|
||||||
type MessageNametagBuffer struct {
|
type MessageNametagBuffer struct {
|
||||||
buffer []MessageNametag
|
buffer []MessageNametag
|
||||||
counter uint64
|
counter uint64
|
||||||
|
|
Loading…
Reference in New Issue