0

I have integrated Swift Crypto, the example shows how to generate a new private key\public key, then sign.

    let signingKey = try P256.Signing.PrivateKey()
    let signature = try signingKey.signature(for: hash)

but I want to use a given privatekey, just like the code in nodejs

  import { ecsign} from 'ethereumjs-util';
  const { r, s, v } = ecsign(hash, Buffer.from(givenPivatekey, 'hex'));
  const signature = Buffer.concat([ r, s ]);

so what's the solution

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 03 '22 at 06:20

1 Answers1

0

Well. Let me end the the question by my own. link the libsecp256k1.a in my project use secp256k1_ecdsa_recoverable_signature

  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 06 '22 at 15:25