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

DSA #5

Open
inm7ripe opened this issue Sep 5, 2021 · 5 comments
Open

DSA #5

inm7ripe opened this issue Sep 5, 2021 · 5 comments

Comments

@inm7ripe
Copy link

inm7ripe commented Sep 5, 2021

Hello Martin!

Is it possible to use your approach with a minor changes for DSA?

WBR,
Igor

@malb
Copy link
Owner

malb commented Sep 5, 2021

@factorable is the real expert here but AFAIK yes, if you're up for writing a bit of code.

@factorable
Copy link
Collaborator

It depends what you mean by "minor changes". The exact same algorithmic approach works for DSA, but unfortunately the code in ecdsa_hnp.py is basically littered with curve operations that will need to be changed, basically everything having to do with parsing input and checking the predicate. You'll only need to modify ecdsa_cli.py and ecdsa_hnp.py, though. The pycrypto library should help with DSA public key parsing.

@inm7ripe
Copy link
Author

Thanks a lot and some stupid questions:

  1. I've done some modification in code in functions _data_for_test and predicate in addition to input parser
    _data_for_test:
    G_powers[Integer(M.B[row][0] / f)] = power_mod(self.ecdsa.g,Integer(M.B[row][0] / f),self.ecdsa.p) % self.ecdsa.q
    G_powers[w] = power_mod(self.ecdsa.g,w,self.ecdsa.p) % self.ecdsa.q
    predicate:
    if kG * G_powers[w] % self.ecdsa.p % self.ecdsa.q == r:
    return True
    elif -kG * G_powers[w] % self.ecdsa.p % self.ecdsa.q == r:
    return True
    Is it correct?
  2. Can you give me a hint about other function modification ( volf, ghf, evf ...) ?
    Thanks in advance!
    WBR,
    Igor

@malb
Copy link
Owner

malb commented Sep 15, 2021

Hi Igor, FWIW I'd say a better way to go about this is to create a fresh dsa_hnp.py file which constructs the lattice for DSA, without any EC references in there. I think the volume, expected length etc should be analogous to how it's done for ECDSA. Doing this as an independent class/file means it will be much easier to see what needs to happen and where. Most of the lattice magic is hidden in usvp.py anyway, so this can be easily reused.

@inm7ripe
Copy link
Author

inm7ripe commented Sep 15, 2021

I totally agree with you. DSA code should be located in a separate class for a full-fledged project, but currently I'm afraid I'm confused with shifting from elliptic curve point operations to power mod operations, so I'm using "if self.is_dsa:" hack to place DSA related code and debug it. Unfortunately in my case predicate function always return "false" , so I asked my previous question number one.

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

3 participants