Page MenuHomePhabricator

[ecash-lib] Add `PkcAlgo` to verify common elliptic curve and RSA signatures
ClosedPublic

Authored by tobias_ruck on Tue, May 20, 12:40.

Details

Summary

This allows us to verify signatures of X509 certificates, which is important for BIP70.

We use the ring crate to verify signatures in WebAssembly. On GitHub, it says that it is "an experiment", but the crate has been around for 10 years and seems to be very widely used, and it also works very well with WASM.

Keys are generated with a bash script genkeys.sh via openssl to assert we stay compatible with it. Generated keys are committed in the repo to ease debugging and reproducibility, if needed.

This increases the bundle size of CashTab by 28.73kB after gzip, which is very reasonable.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tobias_ruck retitled this revision from [ecash-lib] Add `PkcAlgo` to verify common clliptic curve and RSA signatures to [ecash-lib] Add `PkcAlgo` to verify common elliptic curve and RSA signatures.Tue, May 20, 12:41

wait for build

Fabien requested changes to this revision.Tue, May 20, 13:22
Fabien added inline comments.
modules/ecash-lib/genkeys.sh
5 ↗(On Diff #54099)

Macro whatyearisit:

also this should be on top

modules/ecash-lib/src/publicKeyCrypto.test.ts
1 ↗(On Diff #54099)

Macro whatyearisit:

23 ↗(On Diff #54099)

does this work if not run from the current dir ?

37 ↗(On Diff #54099)

style nit: you could group in a associative array oid => name for readability, and loop

modules/ecash-lib/src/publicKeyCrypto.ts
1 ↗(On Diff #54099)

not repeating because it gets boring

This revision now requires changes to proceed.Tue, May 20, 13:22
modules/ecash-lib/genkeys.sh
5 ↗(On Diff #54099)

2025

Can't be on top, but I can move the LC_ALL down

modules/ecash-lib/src/publicKeyCrypto.test.ts
1 ↗(On Diff #54099)

2025

23 ↗(On Diff #54099)

yes, and current dir is /modules/ecash-lib

37 ↗(On Diff #54099)

hmm, but what's the advantage of that? seems like it's just reformatting the same thing

also this way we get a nice clean error with the offending line

modules/ecash-lib/src/publicKeyCrypto.ts
1 ↗(On Diff #54099)

computers repeat the same thing billions of times per second and it doesn't get boring for them 🤔

It's the current year!

Also move copyright notice up a bit

Fabien added inline comments.
modules/ecash-lib/src/publicKeyCrypto.ts
1 ↗(On Diff #54099)

The only conclusion is that I'm not a computer. I hope you're not disappointed.

This revision is now accepted and ready to land.Tue, May 20, 14:27