ontio / ontology-ts-sdk

Comprehensive TypeScript library for the Ontology blockchain.
GNU Lesser General Public License v3.0
64 stars 39 forks source link

Invalid y value for curve on require('ontology-ts-sdk') #214

Open congminh090800 opened 3 years ago

congminh090800 commented 3 years ago

I got this error right at the require step

2021-07-28 09:37:19.427 ERROR 8476 Logger get balance and amount job error: Error: Invalid y value for curve.
    at Point.validate (/home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/bitcore-lib/lib/crypto/point.js:123:11)
    at new PresetCurve (/home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/elliptic/lib/elliptic/curves.js:22:17)
    at Object.get [as p256] (/home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/elliptic/lib/elliptic/curves.js:32:19)
    at new EC (/home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/elliptic/lib/elliptic/ec/index.js:22:21)
    at Module.<anonymous> (/home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/@ont-dev/hdkey-secp256r1/lib/index.js:1:1814)
    at t (/home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/@ont-dev/hdkey-secp256r1/lib/index.js:1:124)
    at /home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/@ont-dev/hdkey-secp256r1/lib/index.js:1:923
    at Object.<anonymous> (/home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/@ont-dev/hdkey-secp256r1/lib/index.js:1:932)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/minhlpc/Desktop/staking-childpool-admin-web-backend/node_modules/ontology-ts-sdk/lib/index.js:1:2731)

Got stuck in this line:

  if (p2.y.cmp(this.y) !== 0) {
    throw new Error('Invalid y value for curve.');
  }

Is there something new on curve function ?

sinanouri commented 1 year ago

same error

const bip39 = require("bip39");
const hdkey = require('hdkey');
const { Account, Crypto } = require('ontology-ts-sdk')
function ont(data) {
    const mnemonic = data.mnemonic
    const mnemonicPath = data.mnemonicPath
    const seed = bip39.mnemonicToSeedSync(mnemonic);
    const hdWallet = hdkey.fromMasterSeed(seed).derive("m/0'/0'/0'/" + mnemonicPath + "'");
    const child = hdWallet._privateKey.toString('hex')
    const privateKey = new Crypto.PrivateKey(child);
    const account = Account.create(privateKey, '', 'account');
    const WIF = privateKey.serializeWIF();
    const address = account.address.toBase58()
    return { address: address, privateKey: WIF }
}
module.exports = {
    ont
}
sinanouri commented 1 year ago

@congminh090800 could you do anything about it since 2021? :))