Coder Social home page Coder Social logo

Comments (7)

paulmillr avatar paulmillr commented on June 14, 2024 1

@Cali93 if you'll find something good, please post it here - I will want to add it to README for documentation purposes

from noble-ed25519.

paulmillr avatar paulmillr commented on June 14, 2024 1

@Cali93 default async methods require webcrypto sha512. Since it's not present there, your best bet is to enable synchronous methods and use them with noble-hashes. See readme for usage.

from noble-ed25519.

paulmillr avatar paulmillr commented on June 14, 2024

I think it's because React Native doesn't support crypto by default.

It's all supported. Something is wrong with your config.

You will need to write down the exact steps and errors.

from noble-ed25519.

Cali93 avatar Cali93 commented on June 14, 2024

I updated the issue with more details and steps to reproduce.
I face the same issue using node 16 and 18.

from noble-ed25519.

paulmillr avatar paulmillr commented on June 14, 2024

Okay. It seems like React Native still doesn't support webcrypto: facebook/hermes#915.

Is there a recommended way to get it working on React Native (with and without using Expo) ? Could you document the steps ?

Use polyfill. There should be some, because a lot of people are using noble with webcrypto.

I don't develop RN apps so I can't say which one I would recommend.

from noble-ed25519.

Cali93 avatar Cali93 commented on June 14, 2024

Most of the library is working by using react-native-quick-crypto to polyfill crypto.
However I get Cannot read property 'digest' of undefined when calling sign or signAsync.

from noble-ed25519.

Cali93 avatar Cali93 commented on June 14, 2024

I got the library working on react-native!

Here's the process to get it working if you want to add it in the documentation.

  1. Install and set up react-native-quick-crypto to polyfill crypto.
  2. Add the following snippet in the index.js file of your react-native app
import crypto from 'react-native-quick-crypto';

const polyfillDigest = async (algorithm, data) => {
  const algo = algorithm.replace('-', '').toLowerCase();
  const hash = crypto.createHash(algo);
  hash.update(data);
  return hash.digest();
};

globalThis.crypto = crypto;
globalThis.crypto.subtle = {
  digest: polyfillDigest,
};

I hope it helps others using this great library in react-native.

from noble-ed25519.

Related Issues (20)

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.