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

feat(signer): add ECDSA proxy keys #87

Merged
merged 38 commits into from
Aug 30, 2024
Merged

Conversation

David-Petrov
Copy link
Collaborator

@David-Petrov David-Petrov commented Aug 14, 2024

Quick summary:

The first two commits are the main content of this PR, so changes are roughly two-fold:

  • refactor of existing infrastructure to prepare support for different signature schemes (other than BLS) for proxy signatures;
  • actually implementing ECDSA as a second signature scheme, whilst further refining the multiple signature infrastructure in the process.

The rest of the commits are smaller decisions and easier to follow.

Update 1

From eba97b0 below, the PR takes an alternative approach to implementing ECDSA proxies where we strive to flatten the flow by losing the generics and making the client SDK more type safe.

TODOs:

  • Take care of local inline TODOs.
  • Better serialization to request/response structs for a proper REST API
  • Update Signer API docs (with examples).
  • Add tests for the ECDSA keys.

fixes #20

David-Petrov and others added 5 commits August 9, 2024 17:19
Co-authored-by: reo101 <pavel.atanasov2001@gmail.com>
Co-authored-by: reo101 <pavel.atanasov2001@gmail.com>
- simplify internals of `EcdsaPublicKey`: no need to store the actual abstract object, just its compressed encoding - we construct it when needed
- extract verification logic into a separate trait `Verifier`, not in `SecretKey`
- remove some (already) obsolete utility functions from `signature.rs`
@David-Petrov David-Petrov force-pushed the feat/ecdsa-proxy-keys branch from c88ef02 to a9ff828 Compare August 14, 2024 11:01
@David-Petrov David-Petrov marked this pull request as ready for review August 14, 2024 13:55
@David-Petrov David-Petrov requested review from ltitanb and fbrv August 14, 2024 13:55
@David-Petrov David-Petrov force-pushed the feat/ecdsa-proxy-keys branch from 76b1fda to 377aa78 Compare August 15, 2024 11:00
@David-Petrov David-Petrov changed the title Add ECDSA proxy keys feat(signer): add ECDSA proxy keys Aug 15, 2024
* also, a small fix with error handling (avoid panicking)
Copy link
Collaborator

@ltitanb ltitanb left a comment

Choose a reason for hiding this comment

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

  • other changes as discussed

crates/common/src/signature.rs Outdated Show resolved Hide resolved
crates/common/src/signer/schemes/ecdsa.rs Show resolved Hide resolved
- flatten out the code structure by removing generics
- TODO: client SDK still not typed straightforward, but with enums
  insteand
- thus, conclude an implementation variant where ECDSA and BLS types are separated almost everywhere throughout the signer module (+the client SDK)
@David-Petrov David-Petrov force-pushed the feat/ecdsa-proxy-keys branch from 9ac30c9 to fede09c Compare August 21, 2024 16:11
… key type

* also, introduce the `PublicKey` trait

* TODO: a custom wrapper type around `BlsPublicKey` was necessary in order to implement `TreeHash` trait for it. Refine the boundaries of usage of alloy's type and our custom wrapper.
Copy link
Collaborator

@ltitanb ltitanb left a comment

Choose a reason for hiding this comment

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

Let's make sure to add tests for all new keys + signarures

crates/common/src/commit/client.rs Outdated Show resolved Hide resolved
crates/common/src/commit/client.rs Outdated Show resolved Hide resolved
crates/common/src/commit/client.rs Outdated Show resolved Hide resolved
// derive_more
#[derive(Deref, From, Into)]
pub struct BlsPublicKey {
inner: BlsPublicKeyInner,
Copy link
Collaborator

Choose a reason for hiding this comment

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

if this is just to re-implement TreeHash maybe let's also open an issue upstream?

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 had a quick thought about what we can do regarding opening an issue upstream, but I decided for a wrapper type as a common solution. Now that you propose it, I will have a deeper look into how easy this would be (or maybe if the trait is intentionally not implemented); and eventually open up an issue.

Copy link
Collaborator Author

@David-Petrov David-Petrov Aug 27, 2024

Choose a reason for hiding this comment

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

Opened up the issue here.

Implementing the required changes in tree_hash locally wasn't a problem, but then I had a lot of versioning issues, which tie into this task, so I can't say I've got a working PoC of this approach, thus I've not opened a PR in tree_hash's repo.

Leaving the wrapper type as a temporary solution for now.

Added a TODO in dea0b0c; minimal reexport (as relevant for the wrapper type) in f103c8d

…ic key type

thus remove `SignProxyBlsRequest` and `SignProxyEcdsaRequest` as duplicated structs
@David-Petrov David-Petrov self-assigned this Aug 23, 2024
Cargo.toml Outdated Show resolved Hide resolved
makes deserialization of signatures properly fallible

* also, add both proxy examples in `da_commit`
* replace derived Serialize/Deserialize with sane API ser/de
* hex encode fields properly
* simplify the inner types of `EcdsaPublicKey` and `EcdsaSignature` to native rust arrays
for the current scale of our needs, we can do without a common (unifying) type for both public key types (BLS and ECDSA), so we basically separate into two separate flows which have only the `PublicKey` trait in common, and that's with a really narrow scope mainly for client-side convenience.
crates/common/src/commit/client.rs Outdated Show resolved Hide resolved
crates/common/src/commit/client.rs Show resolved Hide resolved
crates/common/src/commit/request.rs Show resolved Hide resolved
crates/common/src/signer/schemes/bls.rs Show resolved Hide resolved
crates/common/src/signer/schemes/ecdsa.rs Show resolved Hide resolved
@David-Petrov David-Petrov merged commit f1e6ff1 into main Aug 30, 2024
4 checks passed
@David-Petrov David-Petrov deleted the feat/ecdsa-proxy-keys branch August 30, 2024 08: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.

Add support for ECDSA proxy delegation
3 participants