Skip to content

Commit

Permalink
fix: avoid s-expression encoding problem by using hex encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
smlx committed Jul 26, 2021
1 parent 4f9db13 commit 7c29bd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/assuan/assuan.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (a *Assuan) sign() ([]byte, error) {
return nil, fmt.Errorf("couldn't read s as asn1.Integer")
}
// encode the params (r, s) into s-exp
sexp := fmt.Sprintf(`D (7:sig-val(5:ecdsa(1:r32:%s)(1:s32:%s)))`,
r.Bytes(), s.Bytes())
return []byte(sexp), nil
return []byte(fmt.Sprintf(`D (7:sig-val(5:ecdsa(1:r32#%s#)(1:s32#%s#)))`,
hex.EncodeToString(r.Bytes()),
hex.EncodeToString(s.Bytes()))), nil
}
2 changes: 1 addition & 1 deletion internal/assuan/assuan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestSign(t *testing.T) {
"OK\n",
"OK\n",
"OK\n",
"\x44\x20\x28\x37\x3a\x73\x69\x67\x2d\x76\x61\x6c\x28\x35\x3a\x65\x63\x64\x73\x61\x28\x31\x3a\x72\x33\x32\x3a\x2e\xeb\xa5\x1c\xc8\x02\xed\xf6\xac\xf4\x4c\xb6\xb2\x50\x6b\xfe\xda\x87\x27\xcf\x9f\x62\x39\x39\x42\x0b\xcc\xd0\x2f\x2c\x1b\x89\x29\x28\x31\x3a\x73\x33\x32\x3a\x8a\x3d\x09\xe0\xa2\xfe\xd8\x68\x02\xd6\xc6\xe2\xa4\x29\xff\x97\xf9\x8b\x5f\xc9\x88\x04\x42\x74\x5c\x6d\x2f\x45\x57\x10\x40\x70\x29\x29\x29\x0a",
"D (7:sig-val(5:ecdsa(1:r32#2eeba51cc802edf6acf44cb6b2506bfeda8727cf9f623939420bccd02f2c1b89#)(1:s32#8a3d09e0a2fed86802d6c6e2a429ff97f98b5fc9880442745c6d2f4557104070#)))\n",
"OK\n",
},
},
Expand Down

0 comments on commit 7c29bd0

Please sign in to comment.