algorand / algorand/js-algorand-sdk

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

Aperta
#863 3 commenti 1 reazione 0 assegnatari Vedi su GitHub
new-feature-request
Lingua principale
TypeScript
Stelle
297
Fork
214
Merge medio
1h 3m
PR unite (30g)
3

Descrizione

## 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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.