Skip to content

Commit

Permalink
updated to use new openssl dependency on android
Browse files Browse the repository at this point in the history
  • Loading branch information
ronickg committed Oct 27, 2024
1 parent 0b01bc2 commit e082e30
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 60 deletions.
106 changes: 53 additions & 53 deletions example/ios/NitroExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- Bip39 (0.0.1):
- Bip39 (0.0.4):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1824,7 +1824,7 @@ EXTERNAL SOURCES:
:path: "../../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
Bip39: abf590be3656f2d1b3bf2ca0c63adff0b0a2f4de
Bip39: 1f30cc480c2a1b61b98228a4185ec0ab85540c3f
boost: 4cb898d0bf20404aab1850c656dcea009429d6c1
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: 430e10366de01d1e3d57374500b1b150fe482e6d
Expand Down
4 changes: 4 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import * as React from 'react'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { HybridObjectTestsScreen } from './screens/HybridObjectTestsScreen'
import { bip39 } from 'react-native-nitro-bip39'

export default function App() {
React.useEffect(() => {
console.log(bip39.openSSLVersion())
}, [])
return (
<SafeAreaProvider>
<HybridObjectTestsScreen />
Expand Down
3 changes: 2 additions & 1 deletion packages/react-native-nitro-bip39/Bip39.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Pod::Spec.new do |s|
# Implementation (C++ objects)
"cpp/**/*.{hpp,cpp}",
"bip39_cpp/src/*.{cpp}",
"bip39_cpp/include/*.{h}"
"bip39_cpp/include/*.{h}",
"ios/Clibutf8proc.xcframework/**/*.{h,hpp}",
]

s.dependency "OpenSSL-Universal"
Expand Down
5 changes: 3 additions & 2 deletions packages/react-native-nitro-bip39/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ dependencies {
// Add a dependency on NitroModules
implementation project(":react-native-nitro-modules")

implementation 'com.android.ndk.thirdparty:openssl:1.1.1q-beta-1'
implementation 'io.github.cryptorg:utf8proc:2.9.0-beta-1'
implementation 'io.github.ronickg:openssl:3.3.2'
implementation 'io.github.ronickg:utf8proc:2.9.0'
}

7 changes: 7 additions & 0 deletions packages/react-native-nitro-bip39/cpp/HybridBip39.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <sstream>
#include <iomanip>

#include <openssl/crypto.h> // For OpenSSL_version function

#include "bit_opts.h"
#include "langs.h"
#include "mnemonic.h"
Expand Down Expand Up @@ -133,4 +135,9 @@ namespace margelo::nitro::rnbip39
return bip39::GenerateWords(word_list, bip39::GetDelimiterByLang(wordlistStr));
}

std::string HybridBip39::openSSLVersion()
{
return OpenSSL_version(OPENSSL_VERSION);
}

} // namespace margelo::nitro::rnbip39
1 change: 1 addition & 0 deletions packages/react-native-nitro-bip39/cpp/HybridBip39.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace margelo::nitro::rnbip39
std::string mnemonicToSeedHex(const std::string &mnemonic, const std::optional<std::string> &password) override;
std::string mnemonicToEntropy(const std::string &mnemonic, std::optional<WordLists> wordlist) override;
std::string entropyToMnemonic(const std::shared_ptr<ArrayBuffer> &entropy, std::optional<WordLists> wordlist) override;
std::string openSSLVersion() override;

private:
WordLists _defaultWordlist = WordLists::ENGLISH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace margelo::nitro::rnbip39 {
prototype.registerHybridMethod("mnemonicToSeedHex", &HybridBip39Spec::mnemonicToSeedHex);
prototype.registerHybridMethod("mnemonicToEntropy", &HybridBip39Spec::mnemonicToEntropy);
prototype.registerHybridMethod("entropyToMnemonic", &HybridBip39Spec::entropyToMnemonic);
prototype.registerHybridMethod("openSSLVersion", &HybridBip39Spec::openSSLVersion);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace margelo::nitro::rnbip39 {
virtual std::string mnemonicToSeedHex(const std::string& mnemonic, const std::optional<std::string>& password) = 0;
virtual std::string mnemonicToEntropy(const std::string& mnemonic, std::optional<WordLists> wordlist) = 0;
virtual std::string entropyToMnemonic(const std::shared_ptr<ArrayBuffer>& entropy, std::optional<WordLists> wordlist) = 0;
virtual std::string openSSLVersion() = 0;

protected:
// Hybrid Setup
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-nitro-bip39/src/specs/Bip39.nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export type WordLists =

export type WordCount = 12 | 15 | 18 | 21 | 24

export interface Bip39
extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
export interface Bip39 extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
getDefaultWordlist(): WordLists
setDefaultWordlist(value: WordLists): void
generateMnemonic(
Expand All @@ -28,4 +27,5 @@ export interface Bip39
mnemonicToSeedHex(mnemonic: string, password?: string): string
mnemonicToEntropy(mnemonic: string, wordlist?: WordLists): string
entropyToMnemonic(entropy: ArrayBuffer, wordlist?: WordLists): string
openSSLVersion(): string
}

0 comments on commit e082e30

Please sign in to comment.