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

Encryption policies #273

Closed
llbartekll opened this issue Jun 13, 2022 · 1 comment
Closed

Encryption policies #273

llbartekll opened this issue Jun 13, 2022 · 1 comment
Assignees
Milestone

Comments

@llbartekll
Copy link
Contributor

llbartekll commented Jun 13, 2022

To make our jsonrpc serialization more future proof it would be better to create typed envelopes thus making all topics encrypted but only Invite topic would have an envelope that is prefixed with a public key

The typed envelope would allow us to upgrade envelopes in the future as well if needed without breaking existing implementation

Type 0 envelope would use our current serialization and simply prefix it with the type byte

Type 1 envelope would have type byte of 1 and add a public key

So here is the proposed specification that we discussed:

tp = type byte (1 byte)
pk = public key (32 bytes)
iv = initialization vector (12 bytes)
ct = ciphertext (N bytes)

type 0 = tp + iv + ct
type 1 = tp + pk + iv + ct

@llbartekll llbartekll added this to the v2.0-beta.102 milestone Jun 13, 2022
@llbartekll llbartekll self-assigned this Jun 13, 2022
@chadyj
Copy link
Contributor

chadyj commented Jun 14, 2022

From the meeting:

From SDK meeting:

Right now the encrypted message has the format of [ (nonce/iv) + encrypted message + tag ]. This is not possible in the Chat SDK method wc_chatInvite and we have to use the format of [publicKey + (nonce/iv) + encrypted message + tag]. To differentiate them easily we should add envelope type to message payload. For example, in Sign we would have [ 0 + (nonce/iv) + encrypted message ], and for Chat [ 1 +publicKey + (nonce/iv) + encrypted message]

llbartekll added a commit that referenced this issue Jun 21, 2022
…V2 into #273-encryption-policies

# Conflicts:
#	Sources/Chat/NetworkingInteractor.swift
#	Sources/Chat/Serializing.swift
#	Sources/WalletConnectKMS/Codec/ChaChaPolyCodec.swift
#	Sources/WalletConnectKMS/Crypto/CryptoKitWrapper/CryptoKitWrapper.swift
#	Sources/WalletConnectKMS/Crypto/KeyManagementService.swift
#	Sources/WalletConnectKMS/Serialiser/Serializer.swift
#	Sources/WalletConnectSign/NetworkInteractor/NetworkInteractor.swift
#	Sources/WalletConnectSign/Serializing.swift
#	Tests/IntegrationTests/SerialiserTests.swift
#	Tests/TestingUtils/Mocks/KeyManagementServiceMock.swift
#	Tests/WalletConnectSignTests/Mocks/SerializerMock.swift
llbartekll added a commit that referenced this issue Jun 21, 2022
* Add SerializationPolicy type

* savepoint

* savepoint

* Add envelope

* update serialize method

* update envelope

* handle envelope in Sign sdk

* extract envelope to a new file

* add getPublicKey method to kms

* fix kms errors

* fix kms tests

* add kms tests scheme
fix codec tests

* fix serializer tests

* update kms test, fix type 0 envelope key size issue

* simplify serialiser, add envelope init

* Fix envelope type, fix serialiser tests

* remove debugging prints

* update codec docs

* remove unused error

* remove unused error

* move serializing protocol to serializer

* prevent potential crash on envelope init

* add serializing file

* run lint
llbartekll added a commit that referenced this issue Jul 5, 2022
* Add SerializationPolicy type

* savepoint

* savepoint

* Add envelope

* update serialize method

* update envelope

* handle envelope in Sign sdk

* extract envelope to a new file

* add getPublicKey method to kms

* fix kms errors

* fix kms tests

* add kms tests scheme
fix codec tests

* fix serializer tests

* update kms test, fix type 0 envelope key size issue

* simplify serialiser, add envelope init

* Fix envelope type, fix serialiser tests

* remove debugging prints

* update codec docs

* remove unused error

* remove unused error

* move serializing protocol to serializer

* prevent potential crash on envelope init

* add serializing file

* run lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants