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

Problem: zksync eth_signer private key loading security concerns #44

Merged
merged 10 commits into from
Jul 9, 2024

Conversation

JayT106
Copy link
Contributor

@JayT106 JayT106 commented Jun 19, 2024

Solution: trying to add a gCloud KMS signer into SigningEthClientLayer, using google KMS to manage the private key and stores it in the hardware.

There are three environment variables need to be setup before using the Google KMS signer

GOOGLE_APPLICATION_CREDENTIALS - a service account credential file to allow server to access the google KMS services.
GOOGLE_KMS_OP_KEY_NAME - the KMS key path of the eth sender operator. For example:

projects/zkevm-research/locations/northamerica-northeast2/keyRings/gkms_signer_test/cryptoKeys/gkms_signer_op/cryptoKeyVersions/3

The key path format is:

projects/{project}/locations/{region}/keyRings/{keyRing}/cryptoKeys/{key}/cryptoKeyVersions/{version}

It needs to be matched with the google projects setup to able to access the keys in the google kms.

GOOGLE_KMS_OP_BLOB_KEY_NAME(optional) - the KMS key path of the eth sender blob operator.

Note

The zksync V25 start to introduce the node framework for setup the zk node. There for this PR is only for V24.2.0 on our tesetnet for testing purpose. Later on I will migrate it to the upstream and may using zksync config system instead of the environment variables.

Deployment

During the key setup during the network deployment, we can:

  1. Let KMS generate key itself, and no one can know the private key.
  2. Use ethereum secret key (a 32-bytes seed), convert it into pem format using openssl ec -inform, and then can import it into KMS, it requires setup key_import_job on google cloud console.

Once got keys in the KMS. We can attest/verify the key through the google cloud console.
For the network deploy we will need to setup the converted ethereum address relate to these keys and set into the L1 contracts.

@JayT106 JayT106 marked this pull request as draft June 19, 2024 03:23
@JayT106 JayT106 self-assigned this Jun 19, 2024
@JayT106 JayT106 requested review from calvinaco and thomas-nguy June 19, 2024 03:23
@JayT106 JayT106 force-pushed the jt/gkms-signer branch 2 times, most recently from 2ad4540 to 51297c4 Compare June 21, 2024 02:58
@thomas-nguy thomas-nguy requested a review from devashishdxt June 21, 2024 06:35
@JayT106 JayT106 marked this pull request as ready for review June 24, 2024 21:25
Copy link
Member

@thomas-nguy thomas-nguy left a comment

Choose a reason for hiding this comment

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

overall lgtm

core/lib/eth_signer/Cargo.toml Outdated Show resolved Hide resolved
core/lib/eth_signer/src/g_kms_signer.rs Outdated Show resolved Hide resolved
core/lib/eth_signer/src/g_kms_signer.rs Outdated Show resolved Hide resolved
core/lib/eth_signer/src/g_kms_signer.rs Outdated Show resolved Hide resolved
core/lib/zksync_core/src/lib.rs Show resolved Hide resolved
core/lib/zksync_core/src/lib.rs Outdated Show resolved Hide resolved
core/lib/zksync_core/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@calvinaco calvinaco left a comment

Choose a reason for hiding this comment

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

Overall LGTM, have a small question about the use of unwrap().

core/lib/eth_client/src/clients/http/signing.rs Outdated Show resolved Hide resolved
@thomas-nguy
Copy link
Member

Merging this PR

@JayT106 as an improvement, lets add mode in config such as ETH_SENDER_SENDER_SIGNING_MODE

@thomas-nguy thomas-nguy merged commit c1a1d29 into testnet-v24.2.0 Jul 9, 2024
13 of 20 checks passed
JayT106 added a commit that referenced this pull request Jul 11, 2024
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.

3 participants