Moonlight-io / asteroid-sdk-js

5 stars 3 forks source link

method for generation of a neo private key, public key, and address #57

Closed lllwvlvwlll closed 4 years ago

lllwvlvwlll commented 4 years ago

Neo uses secp256r1 curve

lllwvlvwlll commented 4 years ago

For the implementation, I've defined the generation of wallets and keys to support multiple platforms. There is a generic key class which can then be distributed into blockchain specific sdks. For example, in Neo:


const sdk = require('../../dist')
import { wallet } from '@cityofzion/neon-js'

const derivationPath = "m/44'/888'/0'/0/0"
const mnemonic = 'online ramp onion faculty trap clerk near rabbit busy gravity prize employ exit horse found slogan effort dash siren buzz sport pig coconut element'

const keychain = new sdk.Keychain()
keychain.importMnemonic(mnemonic)
keychain.generateSeed("a seed") // if this method isn't called, the default seed is used (ok in most cases)

const key = keychain.generateChildKey('neo', derivationPath) //the key class is generic and can integrate with 3rd party SDKs
const neoAct = new wallet.Account(key.getWIF()) //import the WIF into neon.js

console.log(neoAct.WIF)        //wif:  L3CzS7AnqNtz6SKhbjGGtHUVkQA8DL3CzyPdrTPAwPXVQcB1z7y8
console.log(neoAct.publicKey)  //publicKey:  03dafcce8e57347d7f6f3cc665043c6ace50dfd0c1565132e351ce0e194a4594c3
console.log(neoAct.address)    //address:  AUum8p14W8CVY7rXNmUKnfawokmK6DHXUt
``
lllwvlvwlll commented 4 years ago

@rockacola could you take a look and let me know if you have any questions?

rockacola commented 4 years ago

Example usage is now in asteroid-sdk-js-examples.

Working as expected offline on node.js. Separate test shall be done in vega sandbox once a new asteroid-sdk-js release is available, however I don't see it been problematic.

Let's close out the ticket.