Skip to content

Commit

Permalink
Done
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarnathCJD committed Apr 2, 2022
1 parent 37264e9 commit 631bc67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 4 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,7 @@ const (
ErrBadMsgServerSaltIncorrect BadSystemMessageCode = 48
ErrBadMsgInvalidContainer BadSystemMessageCode = 64
)

func (e *BadMsgError) GetError() string {
return badMsgErrorCodes[uint8(e.Code)]
}
7 changes: 2 additions & 5 deletions handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import (
"github.com/amarnathcjd/gogram/internal/mtproto/objects"
)

// https://tlgrm.ru/docs/mtproto/auth_key
// https://core.telegram.org/mtproto/auth_key
func (m *MTProto) makeAuthKey() error { // nolint don't know how to make method smaller
func (m *MTProto) makeAuthKey() error {
m.serviceModeActivated = true
nonceFirst := tl.RandomInt128()
res, err := m.reqPQ(nonceFirst)
Expand All @@ -46,7 +44,6 @@ func (m *MTProto) makeAuthKey() error { // nolint don't know how to make method
return errors.New("handshake: Can't find fingerprint")
}

// (encoding) p_q_inner_data
pq := big.NewInt(0).SetBytes(res.Pq)
p, q := math.SplitPQ(pq)
nonceSecond := tl.RandomInt256()
Expand All @@ -60,7 +57,7 @@ func (m *MTProto) makeAuthKey() error { // nolint don't know how to make method
ServerNonce: nonceServer,
NewNonce: nonceSecond,
})
check(err) // well, I don’t know what will happen in the universe so that there will panic
check(err)

hashAndMsg := make([]byte, 255)
copy(hashAndMsg, append(dry.Sha1(string(message)), message...))
Expand Down
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package mtproto

import (
"context"
"fmt"
"io"
"log"

"github.com/amarnathcjd/gogram/internal/encoding/tl"
"github.com/amarnathcjd/gogram/internal/mtproto/objects"
Expand Down Expand Up @@ -48,6 +48,6 @@ func CloseOnCancel(ctx context.Context, c io.Closer) {

func check(err error) {
if err != nil {
fmt.Println(err)
log.Println(err)
}
}

0 comments on commit 631bc67

Please sign in to comment.