feat: [NET-1446] Quantum resistant identities and signatures - #3074
Merged
hpihkala merged 59 commits intoApr 29, 2025
Conversation
…antum-resistant-signature-algorithm
teogeb
reviewed
Apr 25, 2025
teogeb
left a comment
Contributor
There was a problem hiding this comment.
Second round of comments (utils, cli-tools, changelog)
teogeb
reviewed
Apr 25, 2025
teogeb
left a comment
Contributor
There was a problem hiding this comment.
Third round of comments (most of the sdk)
teogeb
suggested changes
Apr 25, 2025
teogeb
left a comment
Contributor
There was a problem hiding this comment.
Rest of the comments about sdk.
Great improvements in this PR, with excellent readability 👍
6 tasks
…antum-resistant-signature-algorithm
teogeb
suggested changes
Apr 29, 2025
…antum-resistant-signature-algorithm
teogeb
self-requested a review
April 29, 2025 09:52
hpihkala
deleted the
NET-1446/support-a-quantum-resistant-signature-algorithm
branch
April 29, 2025 13:40
6 tasks
hpihkala
added a commit
that referenced
this pull request
May 7, 2025
## Changes - Add support for ECDSA on `secp256r1` curve. Uses webcrypto (SubtleCrypto) for speed, as that's natively implemented in browsers. - Had to refactor `createSignature` and `verifySignature` in `SigningUtil` interface to be `async`, because webcrypto (SubtleCrypto) only offers async methods. - Offer an `assertValidKeyPair` utility function in all `SigningUtil`s - The previous PR #3074 left some type safety holes in `signingUtils.ts`, they are fixed here. - Unify `EthereumKeyPairIdentity` constructor with other `KeyPairIdentity` constructors. There's now a utility function `EthereumKeyPairIdentity.fromPrivateKey(string)` for creating it from a private key string. - Moved `crossPlatformCrypto.ts` (utility to get `subtle`) from `sdk` package to `utils` package, as it was needed there too. ## Checklist before requesting a review - [x] Is this a breaking change? If it is, be clear in summary. **-> NO** - [x] Read through code myself one more time. - [x] Make sure any and all `TODO` comments left behind are meant to be left in. - [x] Has reasonable passing test coverage? - [x] Updated changelog if applicable. - [x] Updated documentation if applicable.
jtakalai
pushed a commit
that referenced
this pull request
May 20, 2025
## Summary The goal of this PR is to add support for quantum secure cryptographic identities and signatures, as well as to make it easier to add more identity/signature types in the future. The PR includes some refactoring to create a new `Identity` abstraction which replaces the old `Authentication` interface. Most of the line changes are due to renaming things + docs changes. The actual code changes in this PR are actually not that massive. ## Changes **More significant changes:** - Refactor old `Authentication` interface replaced by new `Identity` framework - Added support for ML-DSA-87 identity and signing - As an alternative to configuring keys, allow an `Identity` instance to be passed to `StreamrClient` as `auth.identity` - Add `requireQuantumResistantSignatures` and `requireQuantumResistantEncryption` config options as well as related checks - Add `--public-key` and `--key-type` options to CLI tool - **Breaking change**: In CLI tool, rename `streamr wallet` to `streamr keys` (the only command there was `streamr wallet whoami`, which is now `streamr keys whoami`. Add a new command `streamr keys generate`. - **Breaking change**: Removed `StreamrClient.generateEthereumAccount()`, the new way is `EthereumKeyPairIdentity.generate()` (can be done with other key/identity types as well). - **Breaking change**: The string values in `Message.signatureType` now correspond with the `KeyType` values. This means the previously output value `SECP256K1` is now `ECDSA_SECP256K1_EVM`. - Large-ish docs changes **Additional minor changes:** - Removed some technical debt from `StreamMessageTranslator` by removing `oldContentType` vs. `newContentType`, `oldEncryptionType` vs. `newEncryptionType`. The network-level enums are used directly now. - Give more accurate names to `SignatureType`s, paving the road for more types to be added later. - Namespace the exports in `signingUtils.ts` by algorithm type, eg. `ECDSA_SECP256K1_EVM` and `ML_DSA_87` - Remove `address` as an acceptable parameter to key config - Add a central place `identityConfig.ts` for wiring together identities, `SignatureType`s, and verification methods - Remove repetition / enumeration of SignatureTypes from `Message.ts` and `SignatureValidator.ts` - bugfix: Fix regex used for validating hex strings given to config ## Limitations and future improvements - The client config key `auth` was kept as-is for backwards compatibility, although renaming it to `identity` would probably make sense at some point. - I didn't attempt to solve all overlap or inaccuracies in the docs (there are some). I mainly focused on the Identity article, the articles under the Security section, and any references to them. ## Checklist before requesting a review - [x] Is this a breaking change? If it is, be clear in summary. **(no major breaking changes, but some exported supporting classes have changed)** - [x] Read through code myself one more time. - [x] Make sure any and all `TODO` comments left behind are meant to be left in. - [x] Has reasonable passing test coverage? - [x] Updated changelog if applicable. - [x] Updated documentation if applicable.
jtakalai
pushed a commit
that referenced
this pull request
May 20, 2025
## Changes - Add support for ECDSA on `secp256r1` curve. Uses webcrypto (SubtleCrypto) for speed, as that's natively implemented in browsers. - Had to refactor `createSignature` and `verifySignature` in `SigningUtil` interface to be `async`, because webcrypto (SubtleCrypto) only offers async methods. - Offer an `assertValidKeyPair` utility function in all `SigningUtil`s - The previous PR #3074 left some type safety holes in `signingUtils.ts`, they are fixed here. - Unify `EthereumKeyPairIdentity` constructor with other `KeyPairIdentity` constructors. There's now a utility function `EthereumKeyPairIdentity.fromPrivateKey(string)` for creating it from a private key string. - Moved `crossPlatformCrypto.ts` (utility to get `subtle`) from `sdk` package to `utils` package, as it was needed there too. ## Checklist before requesting a review - [x] Is this a breaking change? If it is, be clear in summary. **-> NO** - [x] Read through code myself one more time. - [x] Make sure any and all `TODO` comments left behind are meant to be left in. - [x] Has reasonable passing test coverage? - [x] Updated changelog if applicable. - [x] Updated documentation if applicable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The goal of this PR is to add support for quantum secure cryptographic identities and signatures, as well as to make it easier to add more identity/signature types in the future. The PR includes some refactoring to create a new
Identityabstraction which replaces the oldAuthenticationinterface.Most of the line changes are due to renaming things + docs changes. The actual code changes in this PR are actually not that massive.
Changes
More significant changes:
Authenticationinterface replaced by newIdentityframeworkIdentityinstance to be passed toStreamrClientasauth.identityrequireQuantumResistantSignaturesandrequireQuantumResistantEncryptionconfig options as well as related checks--public-keyand--key-typeoptions to CLI toolstreamr wallettostreamr keys(the only command there wasstreamr wallet whoami, which is nowstreamr keys whoami. Add a new commandstreamr keys generate.StreamrClient.generateEthereumAccount(), the new way isEthereumKeyPairIdentity.generate()(can be done with other key/identity types as well).Message.signatureTypenow correspond with theKeyTypevalues. This means the previously output valueSECP256K1is nowECDSA_SECP256K1_EVM.Additional minor changes:
StreamMessageTranslatorby removingoldContentTypevs.newContentType,oldEncryptionTypevs.newEncryptionType. The network-level enums are used directly now.SignatureTypes, paving the road for more types to be added later.signingUtils.tsby algorithm type, eg.ECDSA_SECP256K1_EVMandML_DSA_87addressas an acceptable parameter to key configidentityConfig.tsfor wiring together identities,SignatureTypes, and verification methodsMessage.tsandSignatureValidator.tsLimitations and future improvements
authwas kept as-is for backwards compatibility, although renaming it toidentitywould probably make sense at some point.Checklist before requesting a review
TODOcomments left behind are meant to be left in.