Skip to content

Commit

Permalink
Fixed digest size references to 32 (#12)
Browse files Browse the repository at this point in the history
Previously was 64. Actual implementation used 32.
  • Loading branch information
coderofstuff authored Sep 20, 2023
1 parent 062b995 commit 24db710
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kip-0005.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Output: signature associated with that string with some given private key
`PersonalMessageSigningHash` (Transaction hashes uses `TransactionSigningHash` as key to blake2b) and a digest length of `32`
2. Schnorr sign the hashed message

In summary: `schnorr_sign(blake2b(raw_message, digest_size=64, key='PersonalMessageSigningHash'), private_key)`
In summary: `schnorr_sign(blake2b(raw_message, digest_size=32, key='PersonalMessageSigningHash'), private_key)`

### Why hash a message?
1. Reduces the size of some arbitrary message to a fixed length hash
Expand All @@ -49,7 +49,7 @@ Output: `true` if the signature is valid, `false` otherwise
1. Hash the raw message in the same way as above for signing
2. Schnorr verify the signature matches the `public_key` you are testing for

In summary: `schnorr_verify(blake2b(raw_message, digest_size=64, key='PersonalMessageSigningHash'), public_key)`
In summary: `schnorr_verify(blake2b(raw_message, digest_size=32, key='PersonalMessageSigningHash'), public_key)`

# Sample Implementation

Expand All @@ -63,7 +63,7 @@ from secp256k1 import PublicKey, PrivateKey
# some_secret_key (private) and some_public_key (public)
def hash_message(raw_message) -> bytes:
message_hash = blake2b(digest_size=64, key=bytes("PersonalMessageSigningHash", "ascii"))
message_hash = blake2b(digest_size=32, key=bytes("PersonalMessageSigningHash", "ascii"))
message_hash.update(raw_message)
return message_hash.digest()
Expand Down Expand Up @@ -97,4 +97,4 @@ Lorem ipsum dolor sit amet. Aut omnis amet id voluptatem eligendi sit accusantiu
Et aliquid ipsa ut quas enim et dolorem deleniti ut eius dicta non praesentium neque est velit numquam. Ut consectetur amet ut error veniam et officia laudantium ea velit nesciunt est explicabo laudantium sit totam aperiam.
Ut omnis magnam et accusamus earum rem impedit provident eum commodi repellat qui dolores quis et voluptate labore et adipisci deleniti. Est nostrum explicabo aut quibusdam labore et molestiae voluptate. Qui omnis nostrum At libero deleniti et quod quia.
```
```

0 comments on commit 24db710

Please sign in to comment.