algorand / algorand/js-algorand-sdk

rawSignTxn To support only requiring the scalar (not the seed) to sign.

未關閉
#863 3 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
new-feature-request
主要語言
TypeScript
星號
297
分支
214
平均合併
1 小時 3 分鐘
30 天內合併 PR
3

描述

## Problem

Being able to sign transactions with derived keys from schemes like [BIP32-ed25519](https://acrobat.adobe.com/id/urn:aaid:sc:EU:04fe29b0-ea1a-478b-a886-9bb558a5242a), in which only kL (scalar) is known.

The following SDK code in file: `transaction.ts`:

```ts

// returns the raw signature
rawSignTxn(sk: Uint8Array) {
const toBeSigned = this.bytesToSign();
const sig = nacl.sign(toBeSigned, sk);
return Buffer.from(sig);
}

signTxn(sk: Uint8Array) {
// construct signed message
const sTxn: EncodedSignedTransaction = {
sig: this.rawSignTxn(sk),
txn: this.get_obj_for_encoding(),
};
// add AuthAddr if signing with a different key than From indicates
const keypair = nacl.keyPairFromSecretKey(sk);
const pubKeyFromSk = keypair.publicKey;
if (
address.encodeAddress(pubKeyFromSk) !==
address.encodeAddress(this.from.publicKey)
) {
sTxn.sgnr = Buffer.from(pubKeyFromSk);
}
return new Uint8Array(encoding.encode(sTxn));
}

```
Calls "Secret Key" to the Ed25519 seed. Explaining picture below:

![ed25519_image](https://github.com/algorand/js-algorand-sdk/assets/1436105/aba6b82f-b558-41b9-abcb-57f682026f96)

In order to support HDWallets, we need to able to sign with the scalar. We use tweetnacl API's that use **SEED + PublicKey** instead of **a + RH**, which the latter would be preferable when only the scalar and RH is available.

## Solution

Support signing with the scalar instead of the seed (which is known as secret key within the SDK's code)

## Urgency

High - as it blocks the ecosystem from adopting BIP32-ed25519 derived keys and to continue to use the SDK to sign transactions with those derives keys.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。