/
service.go
48 lines (47 loc) · 1.45 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package centrauthsrv
//import (
// "errors"
//
// "github.com/ethereum/go-ethereum/common"
// "github.com/ethereum/go-ethereum/crypto"
// common3 "github.com/iden3/go-iden3/common"
// "github.com/iden3/go-iden3/services/claimsrv"
// "github.com/iden3/go-iden3/utils"
//)
//
//// Auth validates that the given AuthMsg data matches the requirments
//func Auth(authMsg AuthMsg) error {
// err := VerifyChallengeTimestamp(authMsg.Challenge)
// if err != nil {
// return err
// }
//
// sigBytes, err := common3.HexDecode(authMsg.Signature)
// if err != nil {
// return err
// }
//
// // check the authMsg.KSignProof
// proofOfKSign, err := authMsg.KSignProof.Unhex()
// if err != nil {
// return err
// }
//
// // TODO get the Relay address, now it's hardcoded, will be getted from the counterfactual contract of the Relay
// addrBytes, err := common3.HexDecode("0xe0fbce58cfaa72812103f003adce3f284fe5fc7c")
// if err != nil {
// return err
// }
// relayAddr := common.BytesToAddress(addrBytes)
// if !claimsrv.CheckProofClaimUser(relayAddr, proofOfKSign, 140) { //TODO send the address of the Relay, to check the signature of proofOfKSign
// return errors.New("ProofKSign can not be verified")
// }
//
// // verify the Signature of the Challenge with the KSign
// if !utils.VerifySigEthMsg(crypto.PubkeyToAddress(authMsg.KSignPk.PublicKey),
// sigBytes, []byte(authMsg.Challenge)) {
// return errors.New("signature of challenge can not be verified")
// }
//
// return nil
//}