Skip to content

Commit c47eaa8

Browse files
committed
refactor: move toArrayBufferExact function to utils for better code organization
1 parent a484527 commit c47eaa8

2 files changed

Lines changed: 2 additions & 14 deletions

File tree

packages/react-native-quick-crypto/src/diffie-hellman.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ import { NitroModules } from 'react-native-nitro-modules';
22
import type { DiffieHellman as DiffieHellmanInterface } from './specs/diffie-hellman.nitro';
33
import { Buffer } from '@craftzdog/react-native-buffer';
44
import { DH_GROUPS } from './dh-groups';
5-
6-
function toArrayBufferExact(buf: Buffer): ArrayBuffer {
7-
return buf.buffer.slice(
8-
buf.byteOffset,
9-
buf.byteOffset + buf.byteLength,
10-
) as ArrayBuffer;
11-
}
5+
import { toArrayBuffer as toArrayBufferExact } from './utils/conversion';
126

137
export class DiffieHellman {
148
private _hybrid: DiffieHellmanInterface;

packages/react-native-quick-crypto/src/ecdh.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import { NitroModules } from 'react-native-nitro-modules';
22
import type { ECDH as ECDHInterface } from './specs/ecdh.nitro';
33
import { Buffer } from '@craftzdog/react-native-buffer';
4+
import { toArrayBuffer as toArrayBufferExact } from './utils/conversion';
45

56
const POINT_CONVERSION_COMPRESSED = 2;
67
const POINT_CONVERSION_UNCOMPRESSED = 4;
78
const POINT_CONVERSION_HYBRID = 6;
89

9-
function toArrayBufferExact(buf: Buffer): ArrayBuffer {
10-
return buf.buffer.slice(
11-
buf.byteOffset,
12-
buf.byteOffset + buf.byteLength,
13-
) as ArrayBuffer;
14-
}
15-
1610
export class ECDH {
1711
private static _convertKeyHybrid: ECDHInterface | undefined;
1812
private static get convertKeyHybrid(): ECDHInterface {

0 commit comments

Comments
 (0)