0.1.2 • Published 3 years ago
bls12-381-keygen-chia v0.1.2
bls12-381-keygen-chia
This is a fork of bls12-381-keygen adjusting only one line to be compatible with chia's implementation.
BLS12-381 Key Generation compatible with EIP-2333.
If you're looking for actual implementation of the elliptic curve, use module noble-bls12-381. The bls12-381-keygen-chia only generates private keys, by EIP-2333 specification.
Just one small dependency on SHA256.
Usage
Node.js and browser:
npm install bls12-381-keygen-chia
deriveMaster
takesUint8Array
and returnsUint8Array
deriveChild
takesUint8Array, number
and returnsUint8Array
const {deriveMaster, deriveChild} = require('bls12-381-keygen-chia');
const master = deriveMaster(new Uint8Array([0xde, 0xad, 0xbe, 0xef]));
const child = deriveChild(master, 0); // 0 is numeric index
Generating BIP32 seeds for ETH2
const bls = require('noble-bls12-381');
const keygen = require('bls12-381-keygen-chia');
const bip39 = require('bip39');
function eth2PrivFromBytes(bytes, path = 'm/12381/3600/0/0/0') {
const mnemonic = bip39.entropyToMnemonic(bytes);
const seed = bip39.mnemonicToSeedSync(mnemonic);
return keygen.deriveSeedTree(seed, path);
}
function eth2PubFromBytes(bytes, path) {
return bls.getPublicKey(eth2PrivFromBytes(bytes, path));
}
License
MIT (c) Paul Miller (https://paulmillr.com), see LICENSE file.
0.1.2
3 years ago
0.0.1-security
3 years ago