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

Refactor the crypto services #2170

Merged
merged 4 commits into from
Dec 2, 2024
Merged

Conversation

tudor-malene
Copy link
Collaborator

@tudor-malene tudor-malene commented Nov 29, 2024

Why this change is needed

In preparation for MainNet, we must use randomness generated inside the enclave.

What changes were made as part of this PR

  • clarify the responsibilities of the crypto services
  • generate randomness for the da services
  • some wiring required by the random number
  • the RPC key is random. It is now exposed as an RPC endpoint which is called behind the scenes when creating an encrypted connection

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

@tudor-malene tudor-malene changed the title refactor the crypto services and generate true random entropy for da … Refactor the crypto services Nov 29, 2024
Copy link
Collaborator

@BedrockSquirrel BedrockSquirrel left a comment

Choose a reason for hiding this comment

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

LGTM! Big milestone getting rid of that hardcoded key. Couple v minor comments.

Worth getting Stefan/other eyes on it too, the extending entropy stuff seems sensible to me but I don't know if there are gotchas.

Nice that we get away with not having to restart Gateway on testnet redeploy still I think, because the encrypted clients are created on demand 💪

@@ -25,11 +25,6 @@ import (
gethlog "github.com/ethereum/go-ethereum/log"
)

const (
// todo: this is a convenience for testnet testing and will eventually be retrieved from the L1
enclavePublicKeyHex = "034d3b7e63a8bcd532ee3d1d6ecad9d67fca7821981a044551f0f0cbec74d0bc5e"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This key string still appears a few times in the codebase which can probably be cleaned up? In particular can probably delete the stuff about 'EnclavePublicKey' in transaction_injector.go

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good spot. Got rid of them. They weren't used anywhere. Probably a vestige

go/rpc/client.go Outdated
@@ -17,6 +17,7 @@ const (

Health = "ten_health"
Config = "ten_config"
RPCKey = "ten_rPCKey"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if it's case sensitive anyway but this capitalisation seems ugly haha, maybe copilot did that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I called the method RPCKey, and the convention is prefix_{lowerCaseFirstChar}{otherChars}

Copy link
Collaborator

@BedrockSquirrel BedrockSquirrel Nov 29, 2024

Choose a reason for hiding this comment

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

Fair, I'd probably rename it to RpcKey() to fix that if it doesn't break our linter with a comment to explain it keeps the rpc method name nice lol. I guess that method's not super public facing but a little bit.

Copy link
Contributor

@StefanIliev545 StefanIliev545 left a comment

Choose a reason for hiding this comment

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

LGTM, lets open a ticket for removing the decrypt blob from any front end if there isn't one already

@tudor-malene tudor-malene merged commit f3ebdce into main Dec 2, 2024
2 checks passed
@tudor-malene tudor-malene deleted the tudor/generate_rand_secret1 branch December 2, 2024 13:07
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