Git Product home page Git Product logo

Comments (8)

Sajjon avatar Sajjon commented on May 26, 2024 1

@luis7lucho I will be closing this issue then, since neither @mobileapps23 nor @narayanprusty have replied.

@luis7lucho regarding performance, since the project is now a SPM package, the tests are no longer run with optimization flag. I have not found a way of using optimization with tests yet, I created a this StackOverflow question, but no reply yet - I'm pretty sure it is not possible yet... Hopefully soon!

from ellipticcurvekit.

Sajjon avatar Sajjon commented on May 26, 2024 1

@luis7lucho please upvote the SO question, so maybe someone posts an answer, thx!

from ellipticcurvekit.

Sajjon avatar Sajjon commented on May 26, 2024

@mobileapps23 So sorry for slow response, saw this just now... But I think I talked to you on StackOverflow?

Hey what kind of data do you wanna sign/verify?

There are five different initializers of Message. You ought to find a suitable one. Remember that the data should be hashed before signing. Which is why I've added convenience inits such:

init<H>(unhashed: Data, hashFunction: H) where H: HashFunction
    init?<H>(
        unhashed: String,
        encoding: String.Encoding = .default,
        hashFunction: H
    ) where H: HashFunction

and

init?<H>(hashedHex: HexString, hashedBy hashFunction: H) where H: HashFunction

from ellipticcurvekit.

narayanprusty avatar narayanprusty commented on May 26, 2024

@Sajjon still same issue. Can you provide code example?

from ellipticcurvekit.

Sajjon avatar Sajjon commented on May 26, 2024

@narayanprusty look at the unit tests, e.g.: https://github.com/Sajjon/EllipticCurveKit/blob/master/Tests/EllipticCurveKitTests/CurveTests/ECDSATests.swift

which also defines convenience inits:


// MARK: Message init
extension Message {
    init(message: String) {
        self.init(unhashed: message, encoding: .default, hashFunction: SHA256())!
    }

    init(hex: String) {
        self.init(hashedHex: hex, hashedBy: SHA256())!
    }
}

from ellipticcurvekit.

luis7lucho avatar luis7lucho commented on May 26, 2024

Hi, quick one, is there a way to sign without hashing the message?
I am trying to replicate org.web3j.crypto framework which has the option to sign without message hashing (and you also hash with SHA3 if you wanted to) but I can't find a way to sign without message hashing here.
Thanks

from ellipticcurvekit.

Sajjon avatar Sajjon commented on May 26, 2024

@luis7lucho Sounds like you don't really know what you are doing? We ALWAYS hash stuff in crypto. Always. You cannot sign a text document being a couple of hundreds of KB or even MB. That makes no sense. We ALWAYS hash the thing we wanna sign.

So either you already have a hash, then you can you the init in init:hashedHex:hashedBy where whatever you pass into hashedBy is ignored. I'm requiring you to pass a HashFunction (via hashedBy) to force you into thinking about how the data you pass is hashed, explicitly highlighting that everything always should be hashed.

You can also use init:rawData, which is will be the exact same thing as init:hashedHex:hashedBy. But I disencourage that.

So sounds like you don't really know what you are signing...? Which really is what you should sort ought first. What are you signing? When you know what you are signing, why not just use the initializers I encourage you to use, e.g. init:unhashedData:hashFunction which does the hashing for you and where you specify which hash funtion to use.

Makes sense?

from ellipticcurvekit.

luis7lucho avatar luis7lucho commented on May 26, 2024

Hi Sajjon, thanks for the reply.
I was trying to replicate a code from the web3j.crypto library from Android wich lets you create a signature without hashing the message (it has a Bool parameter which you can pass false if you do not wish to hash the message). I am not arguing wether you SHOULD or SHOULD NOT, I agree you always should, but for this particuar scenario I needed that. I got around it eventually anyway, but thanks for your reply :)

I have noticed something on your latests commits, the test and the method to generate a signature takes quite a bit of time, a bit when generating the public key but mostly generating the signature, I have put this on a background thread but wanted to know if there is a way around that?
Thanks

from ellipticcurvekit.

Related Issues (8)

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.