Skip to content

Commit fd42caa

Browse files
authored
fix: my screwups in "cleanup" PR (#850)
1 parent 120d9ca commit fd42caa

File tree

9 files changed

+224
-168
lines changed

9 files changed

+224
-168
lines changed

bun.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"lockfileVersion": 1,
3+
"configVersion": 0,
34
"workspaces": {
45
"": {
56
"dependencies": {

example/ios/Podfile.lock

Lines changed: 156 additions & 156 deletions
Large diffs are not rendered by default.

example/ios/QuickCryptoExample.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@
519519
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
520520
);
521521
OTHER_LDFLAGS = "$(inherited)";
522-
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
522+
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native";
523523
SDKROOT = iphoneos;
524524
SWIFT_ENABLE_EXPLICIT_MODULES = NO;
525525
USE_HERMES = true;

example/src/benchmarks/benchmarks.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,28 @@ export class BenchmarkSuite {
4242
const us = tasks.find(t => t.name === 'rnqc');
4343
const themTasks = tasks.filter(t => t.name !== 'rnqc');
4444

45-
themTasks.map(them => {
46-
const notes = this.notes?.[them.name] ?? '';
45+
if (themTasks.length > 0) {
46+
themTasks.map(them => {
47+
const notes = this.notes?.[them.name] ?? '';
48+
this.addResult({
49+
errorMsg: undefined,
50+
challenger: them.name,
51+
notes,
52+
benchName: b.name,
53+
them: them.result,
54+
us: us?.result,
55+
});
56+
});
57+
} else if (us) {
58+
// No comparison benchmarks, just show rnqc results
4759
this.addResult({
4860
errorMsg: undefined,
49-
challenger: them.name,
50-
notes,
61+
challenger: 'N/A',
62+
notes: '',
5163
benchName: b.name,
52-
them: them.result,
53-
us: us?.result,
64+
them: undefined,
65+
us: us.result,
5466
});
55-
});
67+
}
5668
};
5769
}

example/src/benchmarks/cipher/xsalsa20.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Bench } from 'tinybench';
22
import rnqc from 'react-native-quick-crypto';
3+
import { xsalsa20 as nobleXSalsa20 } from '@noble/ciphers/salsa.js';
34
import type { BenchFn } from '../../types/benchmarks';
45

56
const TIME_MS = 1000;
@@ -33,6 +34,24 @@ const xsalsa20_encrypt_decrypt: BenchFn = () => {
3334
}
3435
});
3536

37+
bench.add('@noble/ciphers/salsa', () => {
38+
// Encrypt
39+
const encrypted = nobleXSalsa20(key, nonce, data);
40+
if (encrypted.length !== data.length) {
41+
throw new Error('Encryption failed: output size mismatch');
42+
}
43+
44+
// Decrypt
45+
const decrypted = nobleXSalsa20(key, nonce, encrypted);
46+
47+
// Verify
48+
for (let i = 0; i < data.length; i++) {
49+
if (data[i] !== decrypted[i]) {
50+
throw new Error(`Decryption verification failed at index ${i}`);
51+
}
52+
}
53+
});
54+
3655
bench.warmupTime = 100;
3756
return bench;
3857
};
@@ -73,6 +92,30 @@ const xsalsa20_encrypt_decrypt_large: BenchFn = () => {
7392
}
7493
});
7594

95+
bench.add('@noble/ciphers/salsa', () => {
96+
// Encrypt
97+
const encrypted = nobleXSalsa20(key, nonce, data);
98+
if (encrypted.length !== data.length) {
99+
throw new Error('Encryption failed: output size mismatch');
100+
}
101+
102+
// Decrypt
103+
const decrypted = nobleXSalsa20(key, nonce, encrypted);
104+
105+
// Verify (checking first and last 100 bytes for performance)
106+
for (let i = 0; i < 100; i++) {
107+
if (data[i] !== decrypted[i]) {
108+
throw new Error(`Decryption verification failed at start index ${i}`);
109+
}
110+
}
111+
112+
for (let i = data.length - 100; i < data.length; i++) {
113+
if (data[i] !== decrypted[i]) {
114+
throw new Error(`Decryption verification failed at end index ${i}`);
115+
}
116+
}
117+
});
118+
76119
bench.warmupTime = 100;
77120
return bench;
78121
};

example/src/navigators/children/BenchmarkDetailsScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const BenchmarkDetailsScreen = ({
2121
const { results, name }: RouteParams = route.params;
2222

2323
return (
24-
<SafeAreaView style={styles.container}>
24+
<SafeAreaView style={styles.container} edges={['left', 'right']}>
2525
<View>
2626
<Text style={styles.title}>Benchmark Results for '{name}' Suite</Text>
2727
</View>

example/src/navigators/children/BenchmarkSuitesScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const BenchmarkSuitesScreen = () => {
1212
let totalCount = 0;
1313

1414
return (
15-
<SafeAreaView style={styles.mainContainer}>
15+
<SafeAreaView style={styles.mainContainer} edges={['left', 'right']}>
1616
<View style={styles.benchmarkList}>
1717
<FlatList
1818
data={suites}

example/src/navigators/children/TestDetailsScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const TestDetailsScreen = ({ route }) => {
2020
const [showPassed, setShowPassed] = useState<boolean>(true);
2121

2222
return (
23-
<SafeAreaView style={styles.container}>
23+
<SafeAreaView style={styles.container} edges={['left', 'right']}>
2424
<View>
2525
<Text style={styles.title}>Test Results for '{suiteName}' Suite</Text>
2626
</View>

example/src/navigators/children/TestSuitesScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const TestSuitesScreen = () => {
1313
let totalCount = 0;
1414

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

0 commit comments

Comments
 (0)