Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get exact sign hash. #59

Open
rachkumar opened this issue Jun 22, 2020 · 0 comments
Open

Get exact sign hash. #59

rachkumar opened this issue Jun 22, 2020 · 0 comments

Comments

@rachkumar
Copy link

Hi I need to get exact hex for a string...what I have tried
   let mnemonic = "xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx"
    let seed = Mnemonic.createSeed(mnemonic: mnemonic)
    let purpose1 = PrivateKey.init(seed: seed, coin: .bitcoin)
    let purpose = purpose1.derived(at: .hardened(44))
    //Bitcoin
    let coinType = purpose.derived(at: .hardened(0))
    // m/44'/0'/0'
    let account = coinType.derived(at: .hardened(0))
    // m/44'/0'/0'/0
    let change = account.derived(at: .notHardened(0))
    // m/44'/0'/0'/0/0
    let firstPrivateKey = change.derived(at: .notHardened(0))
    
    let sign = "1dca0a148623f3f5ce5f49b2abc34384403e545620dca69ceb59da246951b4c3"
    let data = Data.init(hex: sign)
     let signatureData = try! firstPrivateKey.sign(hash: data)
    print(signatureData.hex)

    It gives me wrong hex and Error reading signaturesalid signature, wrong length.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant