Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bun.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"lockfileVersion": 1,
"configVersion": 0,
"workspaces": {
"": {
"dependencies": {
Expand Down
312 changes: 156 additions & 156 deletions example/ios/Podfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/ios/QuickCryptoExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ENABLE_EXPLICIT_MODULES = NO;
USE_HERMES = true;
Expand Down
26 changes: 19 additions & 7 deletions example/src/benchmarks/benchmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,28 @@ export class BenchmarkSuite {
const us = tasks.find(t => t.name === 'rnqc');
const themTasks = tasks.filter(t => t.name !== 'rnqc');

themTasks.map(them => {
const notes = this.notes?.[them.name] ?? '';
if (themTasks.length > 0) {
themTasks.map(them => {
const notes = this.notes?.[them.name] ?? '';
this.addResult({
errorMsg: undefined,
challenger: them.name,
notes,
benchName: b.name,
them: them.result,
us: us?.result,
});
});
} else if (us) {
// No comparison benchmarks, just show rnqc results
this.addResult({
errorMsg: undefined,
challenger: them.name,
notes,
challenger: 'N/A',
notes: '',
benchName: b.name,
them: them.result,
us: us?.result,
them: undefined,
us: us.result,
});
});
}
};
}
43 changes: 43 additions & 0 deletions example/src/benchmarks/cipher/xsalsa20.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Bench } from 'tinybench';
import rnqc from 'react-native-quick-crypto';
import { xsalsa20 as nobleXSalsa20 } from '@noble/ciphers/salsa.js';
import type { BenchFn } from '../../types/benchmarks';

const TIME_MS = 1000;
Expand Down Expand Up @@ -33,6 +34,24 @@ const xsalsa20_encrypt_decrypt: BenchFn = () => {
}
});

bench.add('@noble/ciphers/salsa', () => {
// Encrypt
const encrypted = nobleXSalsa20(key, nonce, data);
if (encrypted.length !== data.length) {
throw new Error('Encryption failed: output size mismatch');
}

// Decrypt
const decrypted = nobleXSalsa20(key, nonce, encrypted);

// Verify
for (let i = 0; i < data.length; i++) {
if (data[i] !== decrypted[i]) {
throw new Error(`Decryption verification failed at index ${i}`);
}
}
});

bench.warmupTime = 100;
return bench;
};
Expand Down Expand Up @@ -73,6 +92,30 @@ const xsalsa20_encrypt_decrypt_large: BenchFn = () => {
}
});

bench.add('@noble/ciphers/salsa', () => {
// Encrypt
const encrypted = nobleXSalsa20(key, nonce, data);
if (encrypted.length !== data.length) {
throw new Error('Encryption failed: output size mismatch');
}

// Decrypt
const decrypted = nobleXSalsa20(key, nonce, encrypted);

// Verify (checking first and last 100 bytes for performance)
for (let i = 0; i < 100; i++) {
if (data[i] !== decrypted[i]) {
throw new Error(`Decryption verification failed at start index ${i}`);
}
}

for (let i = data.length - 100; i < data.length; i++) {
if (data[i] !== decrypted[i]) {
throw new Error(`Decryption verification failed at end index ${i}`);
}
}
});

bench.warmupTime = 100;
return bench;
};
Expand Down
2 changes: 1 addition & 1 deletion example/src/navigators/children/BenchmarkDetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const BenchmarkDetailsScreen = ({
const { results, name }: RouteParams = route.params;

return (
<SafeAreaView style={styles.container}>
<SafeAreaView style={styles.container} edges={['left', 'right']}>
<View>
<Text style={styles.title}>Benchmark Results for '{name}' Suite</Text>
</View>
Expand Down
2 changes: 1 addition & 1 deletion example/src/navigators/children/BenchmarkSuitesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const BenchmarkSuitesScreen = () => {
let totalCount = 0;

return (
<SafeAreaView style={styles.mainContainer}>
<SafeAreaView style={styles.mainContainer} edges={['left', 'right']}>
<View style={styles.benchmarkList}>
<FlatList
data={suites}
Expand Down
2 changes: 1 addition & 1 deletion example/src/navigators/children/TestDetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const TestDetailsScreen = ({ route }) => {
const [showPassed, setShowPassed] = useState<boolean>(true);

return (
<SafeAreaView style={styles.container}>
<SafeAreaView style={styles.container} edges={['left', 'right']}>
<View>
<Text style={styles.title}>Test Results for '{suiteName}' Suite</Text>
</View>
Expand Down
2 changes: 1 addition & 1 deletion example/src/navigators/children/TestSuitesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const TestSuitesScreen = () => {
let totalCount = 0;

return (
<SafeAreaView style={styles.mainContainer}>
<SafeAreaView style={styles.mainContainer} edges={['left', 'right']}>
<View style={styles.testList}>
<ScrollView style={styles.scrollView} testID="test-suites-list">
{Object.entries(suites).map(([suiteName, suite], index) => {
Expand Down