bitcoinjs / tiny-secp256k1

A tiny secp256k1 native/JS wrapper
MIT License
90 stars 55 forks source link

Compatibility: `tiny-secp256k1` vs. `secp256k1-node` #51

Closed eozturk1 closed 3 years ago

eozturk1 commented 3 years ago

secp256k1-node provides functions (See below) for verifying private keys (privateKeyVerify) and generating public keys from them (publicKeyCreate). Are there tiny-secp256k1 equivalents?

// generate privKey
let privKey
do {
  privKey = randomBytes(32)
} while (!secp256k1.privateKeyVerify(privKey))

// get the public key in a compressed format
const pubKey = secp256k1.publicKeyCreate(privKey)
junderw commented 3 years ago
  1. pointFromScalar is publicKeyCreate and isPrivate is privateKeyVerify

pointFromScalar (d[, compressed])

pointFromScalar :: Buffer [-> Bool] -> Maybe Buffer

Returns null if result is at infinity.

Throws:

isPrivate (d)

isPrivate :: Buffer -> Bool

Returns false if


  1. Yes. The private and public keys are compatible between each other.