Skip to content

Commit

Permalink
change hashing order
Browse files Browse the repository at this point in the history
  • Loading branch information
jjanku committed May 6, 2023
1 parent 514969b commit 83286f8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ This is the card reader app for [MultiSchnorrApplet](https://github.com/jjanku/M
```json
{
"group": {
"x": 82621371836311322635731610237257798577123535778674168916413120265184559472745,
"y": 21073772193838990103938873926270519023402430518253746786624584882368307768791
"x": 97451645805052459860544257111023732257189445793566253538963642236580295025715,
"y": 108036769450804252195526975423364810282508296824311571541272318567742502569515
},
"message": "68656c6c6f000000000000000000000000000000000000000000000000000000",
"nonce": {
"x": 28362538501509449895377600989128143307925603662865794767456834195405898871613,
"y": 16208392399936672946292064678176285964271568821992841796429050116123184365933
"x": 49759968054553596793774934369901300558457422800809412179313891716327499250464,
"y": 10595451351086868087048689286043643391031486060528063929912762467167368993502
},
"signature": 104434989019765740973662633870938994847065819938220884369704931829053739864387
"signature": 15093668512161333926586696895604108962007543668405816918671093546412761219977
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ data class Signature(val nonce: ECPoint, val value: BigInteger) {
challengeNonce: ECPoint = nonce
): Boolean {
val challenge = MessageDigest.getInstance("SHA-256").run {
update(challengeNonce.getEncoded(false))
update(challengeKey.getEncoded(false))
update(msg)
update(challengeNonce.getEncoded(false))
BigInteger(1, digest())
}
return value * SchemeParameters.ec.g == nonce + challenge * key
Expand Down
Binary file modified app/src/test/java/com/example/multischnorrreader/applet.jar
Binary file not shown.
12 changes: 6 additions & 6 deletions verify.sage
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ COORD_LEN = (int(p).bit_length() + 7) // 8
data_json = '''
{
"group": {
"x": 82621371836311322635731610237257798577123535778674168916413120265184559472745,
"y": 21073772193838990103938873926270519023402430518253746786624584882368307768791
"x": 97451645805052459860544257111023732257189445793566253538963642236580295025715,
"y": 108036769450804252195526975423364810282508296824311571541272318567742502569515
},
"message": "68656c6c6f000000000000000000000000000000000000000000000000000000",
"nonce": {
"x": 28362538501509449895377600989128143307925603662865794767456834195405898871613,
"y": 16208392399936672946292064678176285964271568821992841796429050116123184365933
"x": 49759968054553596793774934369901300558457422800809412179313891716327499250464,
"y": 10595451351086868087048689286043643391031486060528063929912762467167368993502
},
"signature": 104434989019765740973662633870938994847065819938220884369704931829053739864387
"signature": 15093668512161333926586696895604108962007543668405816918671093546412761219977
}
'''

Expand All @@ -43,6 +43,6 @@ X = E(data['group']['x'], data['group']['y'])
R = E(data['nonce']['x'], data['nonce']['y'])
m = bytes.fromhex(data['message'])
s = data['signature']
c = int.from_bytes(sha256(encode_point(X) + m + encode_point(R)).digest())
c = int.from_bytes(sha256(encode_point(R) + encode_point(X) + m).digest())

assert s * G == R + c * X

0 comments on commit 83286f8

Please sign in to comment.