elliptic icon indicating copy to clipboard operation
elliptic copied to clipboard

Signature validation in python. Prefix configuration?

Open amrbz opened this issue 4 years ago • 0 comments

Hi, Unfortunately can't validate signatures in python with libraries like pynacl (Ed25519). Is it possible to control prefix with this library? Maybe it would solve the problem. Any ideas on that? Thanks.

Python code:

import nacl.signing

def sig_ed():
  message = b'somedata'
  signature = b'2AEB5426A57085F0418BC8AB31A0B3149214916A83C88CF59835099A871E43BCD7E8AD773F4623133247BDE0BF791156C2A38C9D7CB0DDA1C0C4FA2413B4EC07'
  public_key = '25ed5857e12921610ebefd03d508017f0af712bd9a2402e84653a53c067b246e'

  try:
    verify_key = nacl.signing.VerifyKey(public_key, encoder=nacl.encoding.HexEncoder)
    verify_key.verify(message, signature)
  except Exception as error:
    print('error', error)
    return False
  return True

Output:

error Signature was forged or corrupt
False

Similar problems with other curves. In Javascript validation works fine.

amrbz avatar Apr 25 '20 07:04 amrbz