Skip to content

Conversation

@paulmillr
Copy link

@paulmillr paulmillr commented Jan 13, 2025

sr cryptography in 467 lines of js code: https://github.com/paulmillr/micro-sr25519

  • All tests pass
  • There are 2 linting issues which I have 0 ideas how to fix:
packages/util-crypto/src/sr25519/deriveHard.ts
  8:9  error  Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead  @typescript-eslint/unbound-method

packages/util-crypto/src/sr25519/deriveSoft.ts
  8:63  error  Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead  @typescript-eslint/unbound-method

As a side note, this repo's dev infrastructure is slightly idiotic and urgently needs to be improved if the goal is to gain any new outside contributors. It took me 1 hour what should have taken 4 minutes. The test runner takes 3 minutes (too slow, not parallel) - would be great to have an option to crash on a first failed test. README and CONTRIBUTING.md have some bogus rules while not mentioning what's polkadot-dev-run-test and how it works. Linting is non-descriptive: for example, I don't understand what the rule above means (even though i've coded a few js libraries).

This is not really something I "want". This is something that you folks struggle with daily. Imagine how much time you're losing!

@TarikGul
Copy link
Member

For the CI errors, it just needs a yarn install pushed up.

As a side note, this repo's dev infrastructure is slightly idiotic and urgently needs to be improved if the goal is to gain any new outside contributors.

I agree, (preaching to the choir per say). That being said the polkadot-js libs are huge, and so coupled that its hard to make headway with such little bandwidth to spare (Getting way more help soon which should really help move some things forward). That being said the dev infrastructure is all custom implementations or wrappers with no documentation which makes it even more annoying (I've been making some progress on changing that). All in all yes, I agree with your sentiment, when maintenance transferred over to me about a year ago I was left with a bunch of burning fires, a lot have been put out, but there is still much work to be done. Luckily bandwidth will be freeing up soon for me to focus on more QOL goals.


As for the content of the PR, I need to look into this a bit more in depth this week - I love the noble libs as it is, and know a bit of your work (Thank you for all the useful libs you publish) - but I still need to do my due diligence as this would be a big change.

@paulmillr
Copy link
Author

paulmillr commented Jan 14, 2025

@TarikGul micro-sr25519 was funded by polkadot treasury BTW. There was a proposal.

@paulmillr
Copy link
Author

Any updates?

@TarikGul
Copy link
Member

I did look into the error, but couldn't find the source of the issue (yet!). Will continue some efforts tomorrow.

I read the treasury proposal - I'm under the assumption that there are ongoing audits and/or suppose to be audits in the future?

@paulmillr
Copy link
Author

Creator of proposal mentioned they could engage auditors; and I told them that the library should be tested somewhere before audit, because if, while testing, some changes would become necessary, that would invalidate the audit.

Since we have kinda tested the library with this pull request, albeit in a limited way, i’m ok with deferring the merge until post-audit.

@TarikGul
Copy link
Member

i’m ok with deferring the merge until post-audit.

This would be ideal. In the meantime I'll make sure I have a good understanding of this error/issue with the linter so the process for getting this in is smoother once the audit is complete. - Thanks

@mahnunchik
Copy link

@TarikGul @ShankarWarang @farwayer any news?

@TarikGul
Copy link
Member

@TarikGul @ShankarWarang @farwayer any news?

Haven't heard anything yet from my end.

@mahnunchik
Copy link

We are currently blocked from integrating Polkadot into the Coin Wallet until polkadot-js migrates to the lightweight micro-sr25519 library.

@TarikGul
Copy link
Member

We are currently blocked from integrating Polkadot into the Coin Wallet until polkadot-js migrates to the lightweight micro-sr25519 library.

An audit just needs to be completed, and once I hear anything about it - we can start to integrate the following.

@ShankarWarang
Copy link

We are currently blocked from integrating Polkadot into the Coin Wallet until polkadot-js migrates to the lightweight micro-sr25519 library.

An audit just needs to be completed, and once I hear anything about it - we can start to integrate the following.

We have evaluated the audit offerings with 3 firms. We will finalise one and curate an OpenGov proposal for the same.

@valentinfernandez1
Copy link
Contributor

@ShankarWarang any updates on this?

@ShankarWarang
Copy link

@ShankarWarang any updates on this?

The audit engagement by Oak Security (selected firm out of the 3) have been started yesterday and we are expecting the first report on 23rd May.

Timeline updates:

Upcoming:

  • Between 19th - 23rd May: Differential Fuzz Testing (2nd Stream) will be executed by 1 Tester.
  • 23rd May : First Audit Report for the first two streams will be published with all the issues auditors discovered. And the auditors will then be available for 3 weeks to review any fixes from @paulmillr's and/or any other contributor's end.
  • July 28th - August 1st : Additional Security Audit (3rd Stream) by 1 Senior Auditor/Researcher.
  • August 1st : Updated/final audit report from the 3rd stream will be published, including all the issues the auditor discovered. The auditor will then be available for 3 weeks to review any fixes from @paulmillr's and/or any other contributor's end.
  • Upon project completion : Disbursal of the remaining 50% of the audit fee from Edgetributor SubDAO to Oak Security and return the remaining Bridging Buffer to dotPAL bounty.

@paulmillr
Copy link
Author

paulmillr commented Jun 13, 2025

it's done https://github.com/paulmillr/scure-sr25519/tree/main/audit

@TarikGul
Copy link
Member

cc: @valentinfernandez1

We can add this back to the queue :)

@mahnunchik
Copy link

@TarikGul @valentinfernandez1 @ShankarWarang Any news? We won't be adding support for Polkadot until the library switches to a lightweight alternative to wasm.

@ShankarWarang
Copy link

@TarikGul @valentinfernandez1 @ShankarWarang Any news? We won't be adding support for Polkadot until the library switches to a lightweight alternative to wasm.

As the first audit is done, it's up to the maintainers to decide whether they want to use the @scure/sr25519 package now or wait for the additional security audit by the senior auditor/researcher which is scheduled for July 28th to August 1st.

@valentinfernandez1
Copy link
Contributor

valentinfernandez1 commented Aug 22, 2025

Hi @ShankarWarang has the August Audit been completed?? I will start the review as soon as we get confirmation on this.

Also @paulmillr please run yarn lint to fix the failing CI.

@paulmillr
Copy link
Author

@valentinfernandez1 feel free to take over the PR.

@ShankarWarang
Copy link

Hi @ShankarWarang has the August Audit been completed?? I will start the review as soon as we get confirmation on this.

Also @paulmillr please run yarn lint to fix the failing CI.

Yes, the review phase of the Additional Security Audit (3rd Stream) is now officially concluded and the final audit report is published just 2 hours back:
https://github.com/oak-security/audit-reports/tree/main/Polkadot

@paulmillr, will we have a new release for the package or the current latest one is good to go? Thanks 🙌

@paulmillr
Copy link
Author

I wanted to make all my packages ESM-only+node20+, since node.js v20.19+ finally supports loading ESM modules from Common.js. And most people seem to be using babel / other transpilers anyway.

So, the question here is, what should be done here?

  1. Release ESM-only sr25519 today?
  2. Make some adjustments for sr25519 to be ESM+CJS like it was when the PR was created, release, then make another ESM-only release for the future?

Node.js v18 and earlier are no longer supported and don't ship security updates. My suggestion is to also bump the min required ver of polkadot-js to v20. That would allow us to be synced.

@paulmillr
Copy link
Author

In fact, the only high-level thing changed from (already-released) sr25519 v0.2.0 is the RNG commit, which is really low-severity.

I suggest using 0.2.0, if node v18 support is a must-have; then switching to ESM-only 0.3.0 if node v20 minimum is ok.

@ShankarWarang
Copy link

ShankarWarang commented Sep 3, 2025

@valentinfernandez1, @TarikGul, Please let us know if you need any assistance or further clarifications. Looking forward to the adoption of scure-sr25519.
Regards!

@valentinfernandez1
Copy link
Contributor

@paulmillr @ShankarWarang Hey sorry this is taking so long to be merged, as part of our September Audit we also audited this PR just to make sure everything was ok before merging it in.

The Auditors actually found a Medium severity issue that should be addressed 🙏🏻. What is the best way to connect with you guys so I can share the report?

@paulmillr
Copy link
Author

just send me an email, you have it in my profile, no need to complicate anything

@paulmillr
Copy link
Author

and why would you not post the issue publicly if it's only related to this particular PR? The pr has not been merged so it doesn't matter if the issue is public or not

@valentinfernandez1
Copy link
Contributor

The found vulnerability is not related to the PR but rather the micro-sr25519 library itself. So I don't think sharing an exploitable vulnerability is a good idea until it is addressed.

@paulmillr
Copy link
Author

saw the issue and replied by email, to reiterate: not a big deal, we can proceed.

Copy link
Contributor

@valentinfernandez1 valentinfernandez1 left a comment

Choose a reason for hiding this comment

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

Everything looks good just address the merge conflicts and do a yarn lint and we should be good to go

@paulmillr
Copy link
Author

this also needs to be updated to most recent 0.3.0 (or 0.2.0, if node v18 support is a must-have)

@valentinfernandez1
Copy link
Contributor

please add those changes and I can add my final review

@paulmillr
Copy link
Author

@valentinfernandez1 I need to know whether you want to use 0.3 (node v20 and later) or 0.2 (v18)

@valentinfernandez1
Copy link
Contributor

Let's stick to 0.2.0 for backwards compatibility and we can consider upgrading later.

@paulmillr
Copy link
Author

yarn lint passes. i've added // eslint-disable-next-line @typescript-eslint/unbound-method because it's an idiotic rule and I don't know how to fix it. the code doesn't use any this.

What is the best way to fix yarn lockfile conflict?

@paulmillr
Copy link
Author

merged

@paulmillr
Copy link
Author

also no idea how to fix this ci error - which doesn't happen on my machine.

/home/runner/work/common/common/packages/util-crypto/src/sr25519/vrfSign.ts
Error:   4:1  error  Run autofix to sort these imports!  simple-import-sort/imports

the contribution process is too complicated and would reduce amount of new contributors. it's your call, just my 5 cents as an experienced OSS maintainer since 2011. Linting is great in theory but it's a tax.

@valentinfernandez1
Copy link
Contributor

valentinfernandez1 commented Oct 14, 2025

Just yarn lint, as you can see on the CI the lint step failed. After this commit the import was not properly organized so the linting threw an error.

I agree that the way it is currently set up is fairly cumbersome

@paulmillr
Copy link
Author

yarn lint does not output any errors on my machine.

Copy link
Contributor

@valentinfernandez1 valentinfernandez1 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 .

@TarikGul please take a look, will wait to also have your approval before merging.

@paulmillr
Copy link
Author

Note that you're doing a fairly large change with this PR, it was async (waitFor wasm-crypto), now it's sync, perhaps it's not a bad idea to create a second PR after that which bumps minimum node.js requirement to v20 and bumps scure/sr25519 to post-second-audit v0.3

Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

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

Thanks! Looks great.

@valentinfernandez1 Before doing any release we should document the changes from async to sync in this case, and run it upstream against all the libraries (linking).

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.

5 participants