GithubHelp home page GithubHelp logo

fingera / react-native-secp256k1 Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 14.0 191 KB

secp256k1

License: MIT License

CMake 1.79% Java 33.59% JavaScript 13.12% Objective-C 50.10% Ruby 1.41%
secp256k1 react-native bitcoin ecdh aes encrypt decrypt

react-native-secp256k1's Introduction

react-native-secp256k1

Getting started

$ npm install react-native-secp256k1 --save

Mostly automatic installation

$ react-native link react-native-secp256k1

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-secp256k1 and add RNSecp256k1.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNSecp256k1.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNSecp256k1Package; to the imports at the top of the file
  • Add new RNSecp256k1Package() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-secp256k1'
    project(':react-native-secp256k1').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-secp256k1/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-secp256k1')
    

Usage

import secp256k1 from 'react-native-secp256k1';

async function main() {
	const privA = await secp256k1.ext.generateKey();
	const privB = await secp256k1.ext.generateKey();

	const pubA = await secp256k1.computePubkey(privA, true);
	const pubB = await secp256k1.computePubkey(privB, true);

	// sign verify
	const data = "1H1SJuGwoSFTqNI8wvVWEdGRpBvTnzLckoZ1QTF7gI0";
	const sigA = await secp256k1.sign(data, privA);
	console.log("verify: ", await secp256k1.verify(data, sigA, pubA));

	// ecdh && aes256
	const encryped1 = await secp256k1.ext.encryptECDH(privA, pubB, "Hello World");
	const decryped1 = await secp256k1.ext.decryptECDH(privB, pubA, encryped1);
	console.log(decryped1);

	// all: https://github.com/fingera/react-native-secp256k1-demo
}

main().then(() => {
	console.log("Done");
}).catch((err) => {
	console.error(err);
});

react-native-secp256k1's People

Contributors

fingera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-secp256k1's Issues

[up to date] I have a PR to submit

Hey,

I updated the lib so that it is compatible with last versions of RN. Would you add it to this repo and publish it in package manage?

Since it changes the code structure I created a new branch called v1.1 https://github.com/Slals/react-native-secp256k1/tree/v1.1

It doesn't change de core code, it fixes imports and build configs.

I exported the source for iOS in a pod you can find here https://github.com/Slals/bitcoincore-pod-specs

Let me know! If you don't respond I will submit a new package, but it's best to keep it under your name since it's your code.

Please publish latest to cocoapods

Receiving an error when installing:
ERROR | attributes: Missing required attribute "homepage"

I see it has been update on Github but not yet published. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.