Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prerequisite changes for encrypted cloud backup SDK #9154

Merged
merged 84 commits into from
Jan 8, 2022

Conversation

nategraf
Copy link
Contributor

@nategraf nategraf commented Jan 6, 2022

Description

A number of prerequisite changes to the encrypted backup SDK implemented in #8896

  • Refactored @celo/identity and @celo/phone-number-privacy-common packages to make the former depend on the latter. Removed duplicate request and response definitions in @celo/identity.
  • Modify @celo/identity/lib/odis/query to support a NONE authentication option for POPRF queries and to return an augmented error in case fetch throws.
  • Modify rootLogger in @celo/phone-number-privacy-common to be a lazily initialized via a function to avoid import errors when used in other packages.
  • Create io-ts schemas for Domain types to allow for serialization into backups.
  • Add a notBefore output to the SequentialDelayDomain rate limiting predicate to allow for telling the client when they can make their next request.
  • Add disabled to SequentialDelayDomainState and a check in the predicate to respect that state field.
  • Add a NO_GANACHE environment variable flag to the @celo/identity test setup code to more quickly run tests that do not require a mock blockchain.

Tested

Covered by existing tests

Related issues

Backwards compatibility

No concerns

Victor Graf added 30 commits October 22, 2021 17:33
…/celo-monorepo into victor/encrypted-backup-library
@nategraf nategraf requested review from a team, alecps and codyborn and removed request for a team, timmoreton, mcortesi, gastonponti and asaj January 6, 2022 00:43
Copy link
Contributor

@alecps alecps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for giving ODIS this spring cleaning

const bodyString = JSON.stringify(body)

let authHeader = ''
// Sign payload using provided account and authentication method.
// NOTE: Signing and verifying signatures over JSON encoded blobs relies on both the serializer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point. Would a better approach be to parse out the fields and sign them according to a function exposed in phone-number-privacy-common?

Copy link
Contributor Author

@nategraf nategraf Jan 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the main result of this is that anyone who wants to verify the signature over this data must not decode and re-encode it (i.e. they need to save and pass along the original encoded string). This is a situation that seems to be pretty common, including in standards like JWTs, and is not deadly but is unfortunate. I get the sense from what I've read on this topic that its not uncommon for production systems to simply accept the requirement of passing around the originally encoded string. (I was actually talking to my friend this morning about a AWS Sigv4 which has this issue to an extent)

One solution that gets deployed is deterministic encoding rules which are restricted versions of the original encoding rules. Examples include ASN.1 DER which is a subset of BER and is used in certificates, OJSON, and CBOR core deterministic encoding requirements.

In CIP-40, the solution I chose is EIP-712 which provides deterministic "encoding" specifically for the purposes of hashing and signing. With that, the idea is that you can encode, decode and pass around the data to your hearts content and ensure that when its reassembled you will get the same hash. (It also ensures domain seperation to prevent the tail-risk of some colliding message format)

I wouldn't rush to change anything, although if we face any problem with this we may consider using EIP-712 in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks for the detailed explanation. Using eip712 makes a lot of sense

@nategraf nategraf merged commit b65eddd into master Jan 8, 2022
@nategraf nategraf deleted the victor/encrypted-backup-library-base branch January 8, 2022 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants