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

BREAKING: Use SIP-6 algorithm for state encryption #1055

Merged
merged 11 commits into from Dec 14, 2022

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Dec 8, 2022

Closes #944.

This changes the state encryption to use the algorithm as described in SIP-6 for deriving the encryption key. For this, I slightly refactored the deriveEntropy function to take a magic value as extra parameter, and created a new magic value for state encryption.

The encryption logic was moved to the snap_manageState JSON-RPC method.

Breaking changes

  • This breaks existing state, as the encryption keys are now different.
  • The API for the SnapController has changed: it no longer takes a getAppKey parameter.

@Mrtenz Mrtenz force-pushed the mrtenz/sip-6-state-encryption branch from d5a9cde to 1c90783 Compare December 8, 2022 11:59
@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2022

Codecov Report

Merging #1055 (806c0ad) into main (1fe00c8) will increase coverage by 0.42%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1055      +/-   ##
==========================================
+ Coverage   94.13%   94.55%   +0.42%     
==========================================
  Files         132      130       -2     
  Lines        4348     4336      -12     
  Branches      735      734       -1     
==========================================
+ Hits         4093     4100       +7     
+ Misses        255      236      -19     
Impacted Files Coverage Δ
packages/rpc-methods/src/__fixtures__/entropy.ts 100.00% <ø> (ø)
packages/rpc-methods/src/restricted/getEntropy.ts 100.00% <100.00%> (ø)
packages/rpc-methods/src/restricted/manageState.ts 94.73% <100.00%> (+2.00%) ⬆️
packages/rpc-methods/src/utils.ts 75.75% <100.00%> (+48.48%) ⬆️
...ages/snaps-controllers/src/snaps/SnapController.ts 95.07% <100.00%> (-0.13%) ⬇️
packages/snaps-utils/src/entropy.ts 100.00% <100.00%> (ø)
packages/snaps-utils/src/manifest/validation.ts 100.00% <100.00%> (ø)
packages/rpc-methods/src/__fixtures__/index.ts
packages/rpc-methods/src/permitted/index.ts
packages/rpc-methods/src/restricted/index.ts

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Mrtenz Mrtenz marked this pull request as ready for review December 10, 2022 10:21
@Mrtenz Mrtenz requested a review from a team as a code owner December 10, 2022 10:21
@Mrtenz Mrtenz force-pushed the mrtenz/sip-6-state-encryption branch from 602d80b to 29be72b Compare December 14, 2022 13:19
packages/snaps-controllers/src/snaps/SnapController.ts Outdated Show resolved Hide resolved
packages/snaps-utils/src/entropy.ts Outdated Show resolved Hide resolved
packages/snaps-utils/package.json Outdated Show resolved Hide resolved
packages/snaps-controllers/src/snaps/SnapController.ts Outdated Show resolved Hide resolved
packages/rpc-methods/src/restricted/manageState.test.ts Outdated Show resolved Hide resolved
@Mrtenz Mrtenz force-pushed the mrtenz/sip-6-state-encryption branch from 6d3a97a to 819d655 Compare December 14, 2022 15:30
@Mrtenz Mrtenz merged commit 08ac6fa into main Dec 14, 2022
@Mrtenz Mrtenz deleted the mrtenz/sip-6-state-encryption branch December 14, 2022 18:21
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.

Review snap state encryption implementation
3 participants