Skip to content

Commit

Permalink
Update example in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Jan 9, 2016
1 parent 2137327 commit e0510a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ before_install:
env:
global:
- DISPLAY=:99.0
- RANDOM_TESTS_REPEAT=1000
- RANDOM_TESTS_REPEAT=100
matrix:
- CXX=g++-4.8 TEST_SUITE=test
matrix:
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ npm install

# Usage

* [API Reference (v2.x)](API.md)
* [API Reference (v3.x)](API.md)

```js
var crypto = require('crypto')
var secp256k1 = require('secp256k1')
// or require('secp256k1/js')
// if you want to use pure js implementation in node (uses elliptic now)
// or require('secp256k1/elliptic')
// if implementation that uses elliptic package
// if you want to use pure js implementation in node

// generate message to sign
var msg = crypto.randomBytes(32)
Expand All @@ -46,16 +44,16 @@ var msg = crypto.randomBytes(32)
var privKey
do {
privKey = crypto.randomBytes(32)
} while (!secp256k1.secretKeyVerify(privKey))
} while (!secp256k1.privateKeyVerify(privKey))

// get the public key in a compressed format
var pubKey = secp256k1.publicKeyCreate(privKey)

// sign the message
var sigObj = secp256k1.signSync(msg, privKey)
var sigObj = secp256k1.sign(msg, privKey)

// verify the signature
console.log(secp256k1.verifySync(msg, sigObj.signature, pubKey))
console.log(secp256k1.verify(msg, sigObj.signature, pubKey))
```

# LICENSE
Expand Down

0 comments on commit e0510a1

Please sign in to comment.