2.3.1 • Published 3 years ago

react-native-ecc v2.3.1

Weekly downloads
242
License
MIT
Repository
github
Last release
3 years ago

react-native-ecc

basic elliptic curve crypto for React Native

this module is used by Tradle

Installation

See Linking Libraries

Usage

import * as ec from 'react-native-ecc'
import { Buffer } from 'buffer'

// if you want to be able to find your keys
// next time, make sure to use the same service ID 
ec.setServiceID('be.excellent.to.each.other')
// optional
// ec.setAccessGroup('dsadjsakd.com.app.awesome.my')

// this library allows you to sign 32 byte hashes (e.g. sha256 hashes)
const msg = new Buffer('hey ho')
// check ec.curves for supported curves
const curve = 'p256'
ec.keyPair(curve, function (err, key) {
  // pub tested for compatibility with npm library "elliptic"
  const pub = key.pub
  console.log('pub', key.pub.toString('hex'))

  // look up the key later like this:
  // const key = ec.keyFromPublic(pub)

  key.sign({
    data: msg,
    algorithm: 'sha256'
  }, function (err, sig) {
    // signatures tested for compatibility with npm library "elliptic"
    console.log('sig', sig.toString('hex'))
    key.verify({
      algorithm: 'sha256',
      data: msg,
      sig: sig
    }, function (err, verified) {
      console.log('verified:', verified)
    })
  })
})
2.3.1

3 years ago

2.3.0

4 years ago

2.2.0

5 years ago

2.1.0

6 years ago

2.0.0

7 years ago

1.4.0

7 years ago

1.3.0

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago