Commit 4207ed3
committed
chore: assert top bit isn't set
In the xHD lib, the signing function uses
[crypto_scalarmult_ed25519_base_noclamp](https://github.com/algorandfoundation/xHD-Wallet-API-ts/blob/96e7a4be6bca67a4f77252206811f7676e59e5ec/src/x.hd.wallet.api.crypto.ts#L144-L144)
to get the public key which [clears the top
bit](https://github.com/algorandfoundation/xHD-Wallet-API-ts/blob/9849fb3e90cecfb6348e188ff445b55806bfde00/src/sumo.facade.ts#L106-L106).
Then for the signing, the [raw
scalar](https://github.com/algorandfoundation/xHD-Wallet-API-ts/blob/96e7a4be6bca67a4f77252206811f7676e59e5ec/src/x.hd.wallet.api.crypto.ts#L156-L156)
is used without clearing the top bit. Since this is not an exported
function and the keys used are always from the known derivation function
(which ensure the top bit is clear), then this is not an issue. In
AlgoKit, however, we have no guarantees about where the scalar comes
from. As such, it's possible for someone to pass a scalar that does not
have the top bit cleared. The two options are to either clear it
automatically or error, but since a scalar without the top bit cleared
is invalid ed255519 scalar it seems preferable to just throw an error.1 parent d185518 commit 4207ed3
1 file changed
+6
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
0 commit comments