Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/phone-number-privacy/combiner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"db:migrate": "NODE_ENV=dev ts-node scripts/run-migrations.ts"
},
"dependencies": {
"@celo/contractkit": "1.0.2",
"@celo/phone-number-privacy-common": "1.0.33",
"@celo/identity": "1.0.2",
"@celo/contractkit": "1.2.0",
"@celo/phone-number-privacy-common": "1.0.34",
"@celo/identity": "1.2.0",
"@celo/utils": "1.0.2",
"blind-threshold-bls": "https://github.com/celo-org/blind-threshold-bls-wasm#e1e2f8a",
"elliptic": "^6.5.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
GetContactMatchesRequest,
hasValidAccountParam,
hasValidContactPhoneNumbersParam,
hasValidIdentifier,
hasValidUserPhoneNumberParam,
isVerified,
phoneNumberHashIsValidIfExists,
WarningMessage,
} from '@celo/phone-number-privacy-common'
import Logger from 'bunyan'
Expand Down Expand Up @@ -71,7 +71,6 @@ function isValidGetContactMatchesInput(requestBody: GetContactMatchesRequest): b
hasValidAccountParam(requestBody) &&
hasValidUserPhoneNumberParam(requestBody) &&
hasValidContactPhoneNumbersParam(requestBody) &&
!!requestBody.hashedPhoneNumber &&
phoneNumberHashIsValidIfExists(requestBody)
hasValidIdentifier(requestBody)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import {
ErrorMessage,
GetBlindedMessageSigRequest,
hasValidAccountParam,
hasValidQueryPhoneNumberParam,
hasValidTimestamp,
hasValidBlindedPhoneNumberParam,
identifierIsValidIfExists,
isBodyReasonablySized,
MAX_BLOCK_DISCREPANCY_THRESHOLD,
phoneNumberHashIsValidIfExists,
SignMessageResponse,
SignMessageResponseFailure,
SignMessageResponseSuccess,
Expand Down Expand Up @@ -354,10 +353,9 @@ function getMajorityErrorCode(errorCodes: Map<number, number>, logger: Logger) {
function isValidGetSignatureInput(requestBody: GetBlindedMessageSigRequest): boolean {
return (
hasValidAccountParam(requestBody) &&
hasValidQueryPhoneNumberParam(requestBody) &&
phoneNumberHashIsValidIfExists(requestBody) &&
isBodyReasonablySized(requestBody) &&
hasValidTimestamp(requestBody)
hasValidBlindedPhoneNumberParam(requestBody) &&
identifierIsValidIfExists(requestBody) &&
isBodyReasonablySized(requestBody)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('Running against a deployed service', () => {
account: '0x1234',
authenticationMethod: AuthenticationMethod.WALLET_KEY,
blindedQueryPhoneNumber: BLINDED_PHONE_NUMBER,
timestamp: Date.now(),
version: 'ignore',
sessionID: genSessionID(),
}
Expand All @@ -51,7 +50,6 @@ describe('Running against a deployed service', () => {
account: ACCOUNT_ADDRESS,
authenticationMethod: AuthenticationMethod.WALLET_KEY,
blindedQueryPhoneNumber: '',
timestamp: Date.now(),
version: 'ignore',
sessionID: genSessionID(),
}
Expand All @@ -67,7 +65,6 @@ describe('Running against a deployed service', () => {
account: ACCOUNT_ADDRESS,
authenticationMethod: AuthenticationMethod.WALLET_KEY,
blindedQueryPhoneNumber: BLINDED_PHONE_NUMBER,
timestamp: Date.now(),
version: 'ignore',
}
await expect(
Expand All @@ -92,14 +89,12 @@ describe('Running against a deployed service', () => {
describe('With enough quota', () => {
// if these tests are failing, it may just be that the address needs to be fauceted:
// celotooljs account faucet --account 0x1be31a94361a391bbafb2a4ccd704f57dc04d4bb --dollar 1 --gold 1 -e <ENV> --verbose
const timestamp = Date.now()
it('Returns sig when querying with unused and used request', async () => {
await replenishQuota(ACCOUNT_ADDRESS, contractKit)
const body: SignMessageRequest = {
account: ACCOUNT_ADDRESS,
authenticationMethod: AuthenticationMethod.WALLET_KEY,
blindedQueryPhoneNumber: BLINDED_PHONE_NUMBER,
timestamp,
version: 'ignore',
sessionID: genSessionID(),
}
Expand Down
13 changes: 1 addition & 12 deletions packages/phone-number-privacy/combiner/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isVerified, REQUEST_EXPIRY_WINDOW_MS } from '@celo/phone-number-privacy-common'
import { isVerified } from '@celo/phone-number-privacy-common'
import { Request, Response } from 'firebase-functions'
import { BLSCryptographyClient } from '../src/bls/bls-cryptography-client'
import { VERSION } from '../src/config'
Expand Down Expand Up @@ -146,17 +146,6 @@ describe(`POST /getBlindedMessageSig endpoint`, () => {

getBlindedMessageSig(req, invalidResponseExpected(done, 400))
})
it('expired timestamp returns 400', (done) => {
const req = {
body: {
...validRequest,
timestamp: Date.now() - REQUEST_EXPIRY_WINDOW_MS,
},
headers: mockHeaders,
} as Request

getBlindedMessageSig(req, invalidResponseExpected(done, 400))
})
it('invalid blinded phone number returns 400', (done) => {
const req = {
body: {
Expand Down
2 changes: 1 addition & 1 deletion packages/phone-number-privacy/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/phone-number-privacy-common",
"version": "1.0.34-dev",
"version": "1.0.35-dev",
"description": "Common library for the combiner and signer libraries",
"author": "Celo",
"license": "Apache-2.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/phone-number-privacy/signer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/phone-number-privacy-signer",
"version": "1.1.6-dev",
"version": "1.1.8-dev",
"description": "Signing participator of ODIS",
"author": "Celo",
"license": "Apache-2.0",
Expand All @@ -19,9 +19,9 @@
},
"dependencies": {
"@celo/base": "1.1.1",
"@celo/contractkit": "1.0.2",
"@celo/phone-number-privacy-common": "1.0.33",
"@celo/identity": "1.0.2",
"@celo/contractkit": "1.2.0",
"@celo/phone-number-privacy-common": "1.0.34",
"@celo/identity": "1.2.0",
"@celo/utils": "1.0.2",
"@celo/wallet-hsm-azure": "1.0.0-beta3",
"@google-cloud/secret-manager": "3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/phone-number-privacy/signer/src/common/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const Counters = {
labelNames: ['endpoint', 'statusCode'],
}),
databaseErrors: new Counter({
name: 'database_read_errors',
help: 'Counter for the number of database read errors',
name: 'database_errors',
help: 'Counter for the number of database errors',
labelNames: ['type'],
}),
blockchainErrors: new Counter({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Request {

constructor(request: GetBlindedMessagePartialSigRequest) {
this[REQUESTS_COLUMNS.address] = request.account
this[REQUESTS_COLUMNS.timestamp] = new Date(request.timestamp as number)
this[REQUESTS_COLUMNS.timestamp] = new Date()
this[REQUESTS_COLUMNS.blindedQuery] = request.blindedQueryPhoneNumber
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ export async function getRequestExists(
request: GetBlindedMessagePartialSigRequest,
logger: Logger
): Promise<boolean> {
if (!request.timestamp) {
logger.debug('request does not have timestamp')
return false
}
logger.debug({ request }, 'Checking if request exists')
const getRequestExistsMeter = Histograms.dbOpsInstrumentation
.labels('getRequestExists')
.startTimer()
try {
const existingRequest = await requests()
.where({
[REQUESTS_COLUMNS.timestamp]: new Date(request.timestamp as number),
[REQUESTS_COLUMNS.address]: request.account,
[REQUESTS_COLUMNS.blindedQuery]: request.blindedQueryPhoneNumber,
})
Expand All @@ -42,10 +37,6 @@ export async function getRequestExists(
}

export async function storeRequest(request: GetBlindedMessagePartialSigRequest, logger: Logger) {
if (!request.timestamp) {
logger.debug('request does not have timestamp')
return true
}
const storeRequestMeter = Histograms.dbOpsInstrumentation.labels('storeRequest').startTimer()
logger.debug({ request }, 'Storing salt request')
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import {
authenticateUser,
ErrorMessage,
hasValidAccountParam,
hasValidQueryPhoneNumberParam,
hasValidTimestamp,
hasValidBlindedPhoneNumberParam,
identifierIsValidIfExists,
isBodyReasonablySized,
phoneNumberHashIsValidIfExists,
SignMessageResponse,
SignMessageResponseFailure,
WarningMessage,
Expand Down Expand Up @@ -203,10 +202,9 @@ export async function handleGetBlindedMessagePartialSig(
function isValidGetSignatureInput(requestBody: GetBlindedMessagePartialSigRequest): boolean {
return (
hasValidAccountParam(requestBody) &&
hasValidQueryPhoneNumberParam(requestBody) &&
phoneNumberHashIsValidIfExists(requestBody) &&
isBodyReasonablySized(requestBody) &&
hasValidTimestamp(requestBody)
hasValidBlindedPhoneNumberParam(requestBody) &&
identifierIsValidIfExists(requestBody) &&
isBodyReasonablySized(requestBody)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
FULL_NODE_TIMEOUT_IN_MS,
GetQuotaRequest,
hasValidAccountParam,
identifierIsValidIfExists,
isBodyReasonablySized,
isVerified,
phoneNumberHashIsValidIfExists,
RETRY_COUNT,
RETRY_DELAY_IN_MS,
WarningMessage,
Expand Down Expand Up @@ -68,7 +68,7 @@ export async function handleGetQuota(
function isValidGetQuotaInput(requestBody: GetQuotaRequest): boolean {
return (
hasValidAccountParam(requestBody) &&
phoneNumberHashIsValidIfExists(requestBody) &&
identifierIsValidIfExists(requestBody) &&
isBodyReasonablySized(requestBody)
)
}
Expand Down
Loading