()
| 90 | } |
| 91 | |
| 92 | func (kb *Keybase) Validate() (err error) { |
| 93 | kb.Identity = strings.ToLower(kb.Identity) |
| 94 | kb.SignaturePayload = kb.GenerateSignPayload() |
| 95 | kb.AltID = kb.Identity // TODO: maybe get Keybase UserID in another API call? |
| 96 | |
| 97 | url := fmt.Sprintf(URL, kb.Identity, mycrypto.CompressedPubkeyHex(kb.Pubkey)) |
| 98 | kb.ProofLocation = url |
| 99 | resp, err := http.Get(url) |
| 100 | if err != nil { |
| 101 | return xerrors.Errorf("Error when requesting proof: %s", err.Error()) |
| 102 | } |
| 103 | if resp.StatusCode != 200 { |
| 104 | return xerrors.Errorf("Error when requesting proof: Status code %d", resp.StatusCode) |
| 105 | } |
| 106 | body, err := io.ReadAll(resp.Body) |
| 107 | if err != nil { |
| 108 | return xerrors.Errorf("Error when getting resp body") |
| 109 | } |
| 110 | |
| 111 | payload := new(KeybasePayload) |
| 112 | err = json.Unmarshal(body, payload) |
| 113 | if err != nil { |
| 114 | return xerrors.Errorf("error when decoding JSON: %w", err) |
| 115 | } |
| 116 | return kb.validateBody(payload) |
| 117 | } |
| 118 | |
| 119 | func (kb *Keybase) validateBody(payload *KeybasePayload) error { |
| 120 | if payload.Persona != ("0x" + mycrypto.CompressedPubkeyHex(kb.Pubkey)) { |
nothing calls this directly
no test coverage detected