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: add zilliqa schnorr signing #185

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

feri42
Copy link
Contributor

@feri42 feri42 commented Nov 25, 2024

@feri42 feri42 self-assigned this Nov 25, 2024
@feri42 feri42 changed the title refactor: add zilliqa schnorr signing feat: add zilliqa schnorr signing Nov 25, 2024
@feri42 feri42 requested a review from ChALkeR November 25, 2024 18:44
@feri42 feri42 requested a review from a team November 26, 2024 14:37
import { hashSync } from '@exodus/crypto/hash'
import { hmacSync } from '@exodus/crypto/hmac'
import { randomBytes } from '@exodus/crypto/randomBytes'
import * as secp256k1 from '@noble/secp256k1'
Copy link
Contributor

Choose a reason for hiding this comment

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

for reference, the code is based on https://github.com/ExodusMovement/assets/blob/a8fec3450079e64d5fdff5600fa5f4f0aca0d111/zilliqa/zilliqa-lib/src/schnorr.js

question, would the code in asset's zilliqa-lib be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We can directly import @exodus/keychain/module/crypto/secp256k1 for use in the library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless you have a different suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe in the future, an asset won't be able/won't need to define signing, signing is always happing via the keychain. (move funds/import key would break this logic though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would need to add support for adding a private key to the keychain. Not sure what that would look like. Currently the keychain operates by deriving private keys from a seed. This private key would not be associated with a seed.

fboucquez
fboucquez previously approved these changes Nov 26, 2024
@mvayngrib
Copy link
Collaborator

i feel unqualified to review this 😅 , @ChALkeR @kewde ?

@feri42
Copy link
Contributor Author

feri42 commented Nov 26, 2024

i feel unqualified to review this 😅 , @ChALkeR @kewde ?

The code is really just copied from here: https://github.com/ExodusMovement/assets/blob/a8fec3450079e64d5fdff5600fa5f4f0aca0d111/zilliqa/zilliqa-lib/src/schnorr.js#L37 . Don't think we need to review the cryptography itself. But I do need at least concept approval. Or suggestions for a different approach.

mvayngrib
mvayngrib previously approved these changes Nov 27, 2024
Copy link
Collaborator

@mvayngrib mvayngrib left a comment

Choose a reason for hiding this comment

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

@mvayngrib
Copy link
Collaborator

how are zilliqa schnorr sigs diff, can we just use regular schnorr?

@feri42
Copy link
Contributor Author

feri42 commented Nov 27, 2024

how are zilliqa schnorr sigs diff, can we just use regular schnorr?

I won't pretend to understand the differences, but the way I see it is the normal schnorr gets the random entropy once through the extraEntropy parameter and uses a hash of that random value while internally iterating.

The zilliqa schnorr computes a new random value on every iteration.

I'm not even sure there is a quantitative difference there.

Copy link
Contributor

@ChALkeR ChALkeR left a comment

Choose a reason for hiding this comment

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

Concept ack (discussed a while ago)

Did not closely review the code (yet)

Not sure if we should place this in /crypto, but that might take a while, so let's not block this PR -- can move it later

Nit: given the async nature of keychain, this should use async hmac/hash instead, that will make those use native impls in webcrypto contexts

@ChALkeR
Copy link
Contributor

ChALkeR commented Nov 28, 2024

how are zilliqa schnorr sigs diff, can we just use regular schnorr?

@mvayngrib, no, zil has a different schnorr impl
I.e. it's actually different signatures, not convertable, not just a different format
Having a separate impl for it is reasonable (in concept), technical details might need to be worked out

Introducing it somewhere was the plan we discussed about a month ago

@feri42 feri42 dismissed stale reviews from mvayngrib and fboucquez via a72f683 November 28, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants