(req ProofUploadRequest, prev *model.ProofChain, pubkey *ecdsa.PublicKey)
| 71 | } |
| 72 | |
| 73 | func validateProof(req ProofUploadRequest, prev *model.ProofChain, pubkey *ecdsa.PublicKey) (validator.Base, error) { |
| 74 | prev_signature := "" |
| 75 | if prev != nil { |
| 76 | prev_signature = prev.Signature |
| 77 | } |
| 78 | |
| 79 | performer_factory, ok := validator.PlatformFactories[req.Platform] |
| 80 | if !ok { |
| 81 | return validator.Base{}, xerrors.Errorf("platform not supported: %s", string(req.Platform)) |
| 82 | } |
| 83 | created_at, err := util.TimestampStringToTime(req.CreatedAt) |
| 84 | if err != nil { |
| 85 | return validator.Base{}, xerrors.Errorf("error when parsing created_at: %s not recognized", req.CreatedAt) |
| 86 | } |
| 87 | parsed_uuid, err := uuid.Parse(req.Uuid) |
| 88 | if err != nil { |
| 89 | return validator.Base{}, xerrors.Errorf("error when parsing uuid: %s not recognized", req.Uuid) |
| 90 | } |
| 91 | base := validator.Base{ |
| 92 | Platform: req.Platform, |
| 93 | Previous: prev_signature, |
| 94 | Action: req.Action, |
| 95 | Pubkey: pubkey, |
| 96 | Identity: req.Identity, |
| 97 | ProofLocation: req.ProofLocation, |
| 98 | CreatedAt: created_at, |
| 99 | Uuid: parsed_uuid, |
| 100 | } |
| 101 | |
| 102 | if req.Extra.Signature != "" || req.Platform == types.Platforms.Ethereum { |
| 103 | extra := map[string]string{} |
| 104 | extra["wallet_signature"] = req.Extra.EthereumWalletSignature |
| 105 | base.Extra = extra |
| 106 | |
| 107 | persona_sig, err := base64.StdEncoding.DecodeString(req.Extra.Signature) |
| 108 | if err != nil { |
| 109 | return validator.Base{}, xerrors.Errorf("error when decoding persona signature: %w", err) |
| 110 | } |
| 111 | base.Signature = persona_sig |
| 112 | } |
| 113 | |
| 114 | performer := performer_factory(&base) |
| 115 | return base, performer.Validate() |
| 116 | } |
| 117 | |
| 118 | func applyUpload(validator *validator.Base) error { |
| 119 | pc, err := model.ProofChainCreateFromValidator(validator) |
no test coverage detected