Tweak ethereum keys inspired by Bitcoin P2C
var etk = require('eth-tweak-key')
const tweak = crypto.randomBytes(32) // or from some other source
const { tweakedPublicKey, tweakedAddress } = etk.tweakPublic(Buffer.from(keypair.publicKey), tweak)
// The public key must be validated before use, and tweak changed if invalid
etk.validatePublicKey(tweakedPublicKey)
// can now verify signatures with the above
// To do signatures, derive the corresponding private key
const tweakedPrivateKey = etk.tweakPrivate(Buffer.from(keypair.privateKey), tweak)
Byte length of a tweak
Tweak publicKey
with tweak
and optional chainId
. Tweak must be
TWEAKBYTES
. Note that you must pass a copy of publicKey
for now as a
downstream module mutates this.
Returns { publicKey, address }
Validates publicKey
. If false you must choose another public key
Tweak privateKey
with tweak
. Tweak must be TWEAKBYTES
.
Note that you must pass a copy of privateKey
for now as a downstream module
mutates this.
npm install eth-tweak-key