Skip to content

Conversation

@ttodua
Copy link
Member

@ttodua ttodua commented Apr 1, 2025

No description provided.

Comment on lines 648 to 661
unarmorKey(a:string):number[] {
// eslint-disable-next-line no-useless-escape
const m = /-----BEGIN [^-]+-----\n([A-Za-z0-9+\/=\s]+)\n-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/.exec(a);
if (m) {
if (m[1]) {
a = m[1];
} else if (m[2]) {
a = m[2];
} else {
throw new Error("RegExp out of sync");
}
}
return base64.decode(a);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

we shouldn't use this method at all, why do we need it? it is confusing (which might scare some users), does an exec, ... all red flags

Copy link
Collaborator

Choose a reason for hiding this comment

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

btw most crypto libs already properly parse the private key headers

Copy link
Member Author

Choose a reason for hiding this comment

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

about this, I've just copy-pasted that unarmor function from ccxt:
https://github.com/ccxt/ccxt/blob/master/ts/src/base/functions/crypto.ts#L110 (the source is also in ccxt: https://github.com/ccxt/ccxt/blob/master/ts/src/static_dependencies/jsencrypt/lib/asn1js/base64.ts#L74 ), i didn't even look in details of it

as it's bad, we should also remove from ccxt

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ttodua if you check the latest implementation in this branch it does not use any of that

@carlosmiei carlosmiei changed the title private keys support feat: add RSA and ed22519 support Apr 2, 2025
@carlosmiei carlosmiei merged commit 190a64b into master Apr 2, 2025
1 check failed
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.

3 participants