()
| 207 | } |
| 208 | |
| 209 | func (telegram *Telegram) validateText() (err error) { |
| 210 | scanner := bufio.NewScanner(strings.NewReader(telegram.Text)) |
| 211 | for scanner.Scan() { |
| 212 | matched := re.FindStringSubmatch(scanner.Text()) |
| 213 | if len(matched) < 2 { |
| 214 | continue // Search for next line |
| 215 | } |
| 216 | |
| 217 | sigBase64 := matched[1] |
| 218 | sigBytes, err := util.DecodeString(sigBase64) |
| 219 | if err != nil { |
| 220 | return xerrors.Errorf("Error when decoding signature %s: %s", sigBase64, err.Error()) |
| 221 | } |
| 222 | telegram.Signature = sigBytes |
| 223 | return mycrypto.ValidatePersonalSignature(telegram.SignaturePayload, sigBytes, telegram.Pubkey) |
| 224 | } |
| 225 | return xerrors.Errorf("Signature not found in the telegram message.") |
| 226 | } |
| 227 | |
| 228 | func initClient() { |
| 229 | if client != nil { |
no test coverage detected