Skip to content

Commit eac9fdc

Browse files
Apollon77claude
andcommitted
Update react-native-quick-crypto to 1.0.18 and remove ECDSA workaround
QuickCrypto 1.0.18 fixes SubtleCrypto ECDSA sign/verify to return IEEE P1363 format as required by the WebCrypto spec (margelo/react-native-quick-crypto#968). This makes the signEcdsa/verifyEcdsa overrides in ReactNativeCrypto unnecessary since the base StandardCrypto implementation now works correctly with QuickCrypto's subtle API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d889fc4 commit eac9fdc

3 files changed

Lines changed: 98 additions & 122 deletions

File tree

package-lock.json

Lines changed: 95 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@types/node": "^25.3.5",
4141
"react-native-ble-plx": "^3.5.1",
4242
"react-native-polyfill-globals": "^3.1.0",
43-
"react-native-quick-crypto": "^1.0.16",
43+
"react-native-quick-crypto": "^1.0.18",
4444
"react-native-udp": "^4.1.7"
4545
},
4646
"devDependencies": {

packages/react-native/src/crypto/ReactNativeCrypto.ts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@
55
*/
66

77
import { Buffer } from "@craftzdog/react-native-buffer";
8-
import type { Bytes, EcdsaSignature } from "@matter/general";
9-
import {
10-
Crypto,
11-
Entropy,
12-
Environment,
13-
NodeJsCryptoApiLike,
14-
NodeJsStyleCrypto,
15-
StandardCrypto,
16-
WebCrypto,
17-
} from "@matter/general";
8+
import { Crypto, Entropy, Environment, StandardCrypto, WebCrypto } from "@matter/general";
189
import QuickCrypto from "react-native-quick-crypto";
1910

2011
// The default export from QuickCrypto should be compatible with the standard `crypto` object but the type system
@@ -27,27 +18,12 @@ if (!("Buffer" in globalThis)) {
2718
(globalThis as unknown as { Buffer: typeof Buffer }).Buffer = Buffer;
2819
}
2920

30-
// This is probably the crypto implementation we should be building on because QuickCrypto's node.js emulation is more
31-
// mature than their web crypto support. However, for now we just use for API portions where web crypto does not work.
32-
const nodeJsCrypto = new NodeJsStyleCrypto(QuickCrypto as unknown as NodeJsCryptoApiLike);
33-
3421
/**
35-
* Crypto implementation for React Native should work with a WebCrypto basis with 1.x
22+
* Crypto implementation for React Native using WebCrypto via QuickCrypto.
3623
*/
3724
export class ReactNativeCrypto extends StandardCrypto {
3825
override implementationName = "ReactNativeCrypto";
3926

40-
// As of QuickCrypto 1.0.15, subtle.sign() returns DER-encoded ECDSA signatures rather than IEEE P1363 as required
41-
// by the WebCrypto spec. Use Node.js-style crypto instead which handles the encoding correctly.
42-
override async signEcdsa(key: JsonWebKey, data: Bytes | Bytes[]) {
43-
return nodeJsCrypto.signEcdsa(key, data);
44-
}
45-
46-
// See comment for signEcdsa; same thing here
47-
override async verifyEcdsa(key: JsonWebKey, data: Bytes, signature: EcdsaSignature) {
48-
return nodeJsCrypto.verifyEcdsa(key, data, signature);
49-
}
50-
5127
static override provider() {
5228
return new ReactNativeCrypto(crypto as unknown as WebCrypto);
5329
}

0 commit comments

Comments
 (0)