Skip to content

Commit

Permalink
Pass account to be verified to verification service (ethereum#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
asaj authored Oct 17, 2018
1 parent b089c7c commit 845922c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
7 changes: 3 additions & 4 deletions abe/abe.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ func createVerificationMessage(request types.VerificationRequest, verificationRe
return fmt.Sprintf("Celo verification code: %s:%d:%s", base64.URLEncoding.EncodeToString(signature), request.VerificationIndex, base64.URLEncoding.EncodeToString(verificationRewardsAddress.Bytes())), nil
}

func sendSms(phoneNumber string, message string, verificationServiceURL string) error {
// Send the actual text message using our mining pool.
values := map[string]string{"phoneNumber": phoneNumber, "message": message}
func sendSms(phoneNumber string, message string, account common.Address, verificationServiceURL string) error {
values := map[string]string{"phoneNumber": phoneNumber, "message": message, "account": base64.URLEncoding.EncodeToString(account.Bytes())}
jsonValue, _ := json.Marshal(values)
var err error

Expand Down Expand Up @@ -101,7 +100,7 @@ func SendVerificationMessages(receipts []*types.Receipt, block *types.Block, coi
}

log.Debug(fmt.Sprintf("[Celo] Sending verification message: \"%s\"", message), nil, nil)
err = sendSms(phoneNumber, message, verificationServiceURL)
err = sendSms(phoneNumber, message, request.Account, verificationServiceURL)
if err != nil {
log.Error("[Celo] Failed to send SMS", "err", err)
}
Expand Down
17 changes: 10 additions & 7 deletions core/types/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ const (
// VerificationRequest represents a request for verification in the Celo ABE protocol.
type VerificationRequest struct {
PhoneHash common.Hash
CodeHash common.Hash
Account common.Address
VerificationIndex *big.Int
CodeHash common.Hash
Verifier common.Address
EncryptedPhone hexutil.Bytes
}
Expand Down Expand Up @@ -110,23 +111,25 @@ func NewReceipt(root []byte, failed bool, cumulativeGasUsed uint64) *Receipt {
// Decode a VerificationRequest from raw input bytes.
// Input is expected to be encoded in the following manner:
// input[0:32]: bytes32 phoneHash
// input[32:64]: bytes32 codeHash
// input[32:64]: address account
// input[64:96]: bytes32 verificationIndex
// input[96:128]: address verifier
// input[96:] bytes encryptedPhone
// input[96:128]: bytes32 codeHash
// input[128:160]: address verifier
// input[160:] bytes encryptedPhone
func DecodeVerificationRequest(input []byte) (VerificationRequest, error) {
var v VerificationRequest
v.PhoneHash = common.BytesToHash(input[0:32])
v.CodeHash = common.BytesToHash(input[32:64])
v.Account = common.BytesToAddress(input[32:64])
var parsed bool
v.VerificationIndex, parsed = math.ParseBig256(hexutil.Encode(input[64:96]))
if !parsed {
return v, fmt.Errorf("Error parsing VerificationRequest: unable to parse VerificationIndex from " + hexutil.Encode(input[64:96]))
}
v.Verifier = common.BytesToAddress(input[96:128])
v.CodeHash = common.BytesToHash(input[96:128])
v.Verifier = common.BytesToAddress(input[128:160])

// TODO(asa): Consider validating the length of EncryptedPhone
v.EncryptedPhone = input[128:]
v.EncryptedPhone = input[160:]
return v, nil
}

Expand Down

0 comments on commit 845922c

Please sign in to comment.