Comments (8)
@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.
@luis7lucho please upvote the SO question, so maybe someone posts an answer, thx!
from ellipticcurvekit.
@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.
@Sajjon still same issue. Can you provide code example?
from ellipticcurvekit.
@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.
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.
@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.
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)
- Throws an error when running the sample code
- Why is the minimum supported version 11.2 on iOS ? HOT 1
- optimization Config? HOT 2
- How to create PublicKey with hex String or Data
- How about zil domain claims. Iām ok with customizing any eth wallet but Iām still blurred in zilliqa management. HOT 1
- Get PublicKey<Secp256k1> from Data HOT 9
- Support for Secp521R1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ellipticcurvekit.