Skip to content

Conversation

@gugell
Copy link
Contributor

@gugell gugell commented Nov 4, 2025

Description

This pull request introduces native Nitro crypto integration for React Native, updates cryptography dependencies to use patched versions with native support, and improves monorepo compatibility and configuration for the mobile app. The main changes focus on enabling fast, native-backed cryptographic operations (ECDSA, Schnorr) in the mobile environment, updating dependency patching for @noble/curves and @bitcoinerlab/secp256k1, and ensuring the Metro bundler is aware of the new native crypto workspace.

Native crypto integration and dependency patching:

  • Added Nitro-native crypto fast-paths to @bitcoinerlab/secp256k1 and @noble/curves via custom patches, allowing operations like sign, verify, signSchnorr, and verifySchnorr to use the react-native-nitro-avalabs-crypto module when available, with fallback to JS implementations. (.yarn/patches/@bitcoinerlab-secp256k1-npm-1.2.0-1098d4b329.patch [1] .yarn/patches/@noble-curves-npm-1.9.7-2b9efc8ab4.patch [2]
  • Updated package.json to patch all references to @noble/curves and @bitcoinerlab/secp256k1 to ensure the mobile app uses the Nitro-enabled versions. (package.json package.jsonL55-R73)

Monorepo and Metro configuration:

  • Updated packages/core-mobile/metro.config.js to add the Nitro crypto workspace to Metro's watch folders and resolver, ensuring correct module resolution for the new native crypto module. (packages/core-mobile/metro.config.js [1] [2]
  • Added react-native-nitro-avalabs-crypto as a workspace dependency in packages/core-mobile/package.json. (packages/core-mobile/package.json packages/core-mobile/package.jsonR202-R203)

Platform compatibility and workflow improvements:

  • Added browser and react-native shims for Node.js core modules to patched dependencies and package.json files, improving compatibility across platforms. (.yarn/patches/@bitcoinerlab-secp256k1-npm-1.2.0-1098d4b329.patch [1] .yarn/patches/@noble-curves-npm-1.9.7-2b9efc8ab4.patch [2] .yarn/patches/jail-monkey-npm-2.8.0-77e4d06b40.patch [3]
  • Updated Bitrise iOS workflow to install required build tools (autoconf, automake, libtool) for native module compilation. (bitrise.yml bitrise.ymlR218-R220)

Minor improvements and fixes:

These changes collectively enable high-performance native cryptography for React Native, ensure correct dependency resolution across the monorepo, and improve platform compatibility for mobile builds.

Testing

Dev Testing (if applicable)

  • Provide steps to test the happy path of your feature
  • Provide steps to test edge cases and error states
  • Trigger a build on bitrise and reference it here
  • Move the ticket into the "Testing" column on Jira

QA Testing (if applicable)

  • Provide instructions for QA to test this feature thoroughly
  • State expected behavior / acceptance criteria

Checklist

Please check all that apply (if applicable)

  • I have performed a self-review of my code
  • I have verified the code works
  • I have included screenshots / videos of android and ios
  • I have added testing steps
  • I have added/updated necessary unit tests
  • I have updated the documentation

Szymon20000 and others added 9 commits November 4, 2025 22:14
# Conflicts:
#	yarn.lock

fix set problems

stash work

# Conflicts:
#	yarn.lock

stash work

# Conflicts:
#	packages/core-mobile/index.js

performance tracking

# Conflicts:
#	yarn.lock

stash work

make it more solid

fix patch for ios

update sentry

fix patches
@gugell gugell marked this pull request as ready for review November 10, 2025 21:21
@gugell gugell force-pushed the @szymon/nativeCryptoLib branch from 3a99462 to 2f2e959 Compare November 11, 2025 11:15
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you remove these wallet connect patches? they should already be the other wallet connect pr.

stream: require.resolve('./node_modules/stream-browserify'),
'@noble/hashes': require.resolve('./node_modules/@noble/hashes')
'@noble/hashes': require.resolve('./node_modules/@noble/hashes'),
"react-native-nitro-avalabs-crypto": nitroCryptoPath
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need to declare react-native-nitro-avalabs-crypto here. it should already be picked up automatically by metro since it belongs to this workspace.

Comment on lines 46 to 49
nodeModulesPaths: [
path.resolve(workspaceRoot, 'node_modules'),
path.resolve(projectRoot, 'node_modules'),
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need this?

@gugell gugell force-pushed the @szymon/nativeCryptoLib branch 6 times, most recently from b8c5e23 to 24d1dd5 Compare November 19, 2025 21:35
@gugell gugell force-pushed the @szymon/nativeCryptoLib branch from 24d1dd5 to bda4068 Compare November 19, 2025 21:41
# Conflicts:
#	packages/core-mobile/android/app/src/main/AndroidManifest.xml
#	yarn.lock
@gugell gugell force-pushed the @szymon/nativeCryptoLib branch from 0688ea9 to 865584d Compare November 19, 2025 21:43
@gugell gugell force-pushed the @szymon/nativeCryptoLib branch from 8b63168 to ce5e3bc Compare November 24, 2025 17:28
"clean": "rm -rf android/build node_modules/**/android/build lib",
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
"typescript": "tsc",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"typescript": "tsc",
"tsc": "tsc",

since we run yarn tsc for all packages in this repo

Comment on lines 34 to 35
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
"lint": "eslint .",

let's keep only 1 lint here. no need for the --fix also since we already do that when committing.

"README.md"
],
"scripts": {
"postinstall": "tsc || exit 0;",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"postinstall": "tsc || exit 0;",

I don't think we need to run typescript post install

Comment on lines 76 to 93
"eslintConfig": {
"root": true,
"extends": [
"@react-native",
"prettier"
],
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": [
"warn",
{
"quoteProps": "consistent",
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
Copy link
Collaborator

Choose a reason for hiding this comment

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

we already have our own lint setup actually so there is no need to specify eslint rules here. could you follow the same setup as in the packages in this repo? an example is the packages/k2-alpine/.eslintrc.js

@@ -0,0 +1 @@
export * from './Crypto'; No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are 2 index files. looks like one can be removed

if (len & 0x80) {
const n = len & 0x7f
if (n === 0 || n > 2) throw new TypeError('Invalid DER: long len too big')
if (p + n > sig.length) throw new TypeError('Invalid DER: length overflow')
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add tests for these functions?

@gugell gugell force-pushed the @szymon/nativeCryptoLib branch from a9e1f6b to 1e11650 Compare November 26, 2025 12:36
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