Giter Site home page Giter Site logo

Comments (5)

Dimius555 avatar Dimius555 commented on June 15, 2024 1

Ok, sorry, I have just seen your new Readme and there I have found what I'm looking for! Thanks a lot!

from secp256k1.swift.

Dimius555 avatar Dimius555 commented on June 15, 2024

As I read Public Key(65 bits) should be longer then private (32 bits)

from secp256k1.swift.

csjones avatar csjones commented on June 15, 2024

Hey @Dimius555 👋

It seems you're looking for the .uncompressed public key format. Using the different format looks something like this:

secp256k1.Signing.PrivateKey(rawRepresentation: privateBytes, format: .uncompressed)

Here is a test I created with broader usage of the uncompressed public key format based on the data you provided.

let privateBytes = try! "703d3b63e84421e59f9359f8b27c25365df9d85b6b1566e3168412fa599c12f4".bytes
let privateKey = try! secp256k1.Signing.PrivateKey(rawRepresentation: privateBytes, format: .uncompressed)

XCTAssertEqual(privateKey.publicKey.format, .uncompressed)
XCTAssertEqual(privateKey.publicKey.rawRepresentation.count, secp256k1.Format.uncompressed.length)
        
let expectedPublicKeyString = """
 04c9c68596824505dd6cd1993a16452b4b1a13bacde56f80e9049fd03850cce137c1fa4acb7bef7edcc04f4fa29e071ea17e34fa07fa5d87b5ebf6340df6558498
"""

// Define the expected public key
let expectedPublicKey = try! expectedPublicKeyString.bytes

// Verify the generated public key matches the expected public key
XCTAssertEqual(expectedPublicKey, privateKey.publicKey.rawRepresentation.bytes)
XCTAssertEqual(expectedPublicKeyString, String(bytes: privateKey.publicKey.rawRepresentation.bytes))

from secp256k1.swift.

Dimius555 avatar Dimius555 commented on June 15, 2024

Thank you @csjones!

But here is another issue, I see you are using secp256k1.Signing.PrivateKey, I'm trying to use secp256k1.KeyAgreement.PrivateKey and how can I create SharedSecret in this case?

from secp256k1.swift.

Dimius555 avatar Dimius555 commented on June 15, 2024

Screenshot 2022-06-03 at 15 09 58

from secp256k1.swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.