Skip to content

Commit 427e703

Browse files
authored
Merge branch 'main' into pg/diagnosis-report-submit
2 parents a7de0df + 3bb3515 commit 427e703

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

docs/rfcs/payment-topup-sr25519.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "Use Sr25519 Secret Keys in PaymentTopUpSource"
3+
owner: "@filippovecchiato"
4+
---
5+
6+
# RFC — Use Sr25519 Secret Keys in PaymentTopUpSource
7+
8+
## Summary
9+
10+
Change all secret key fields in `PaymentTopUpSource` (RFC 0006) from 32-byte keys to 64-byte Sr25519 secret keys. The `PrivateKey` variant switches from `Ed25519PrivateKey` to `Sr25519SecretKey`, and the `Coins` variant widens its keys to match.
11+
12+
## Motivation
13+
14+
RFC 0006 specified Ed25519 for the `PrivateKey` variant, but the host implementation in triangle-js-sdks uses Sr25519 ([triangle-js-sdks#198](https://github.com/paritytech/triangle-js-sdks/pull/198)). The original RFC was simply wrong at that place — the accounts backing top-ups are Sr25519, not Ed25519. The `Coins` variant already used Sr25519, but with a 32-byte mini-secret; the upstream implementation uses the full 64-byte secret key for both.
15+
16+
## Detailed Design
17+
18+
`PaymentTopUpSource` changes from:
19+
20+
```rust
21+
enum PaymentTopUpSource {
22+
ProductAccount { derivation_index: u32 },
23+
PrivateKey { ed25519_private_key: [u8; 32] },
24+
Coins { sr25519_secret_keys: Vec<[u8; 32]> },
25+
}
26+
```
27+
28+
to:
29+
30+
```rust
31+
enum PaymentTopUpSource {
32+
ProductAccount { derivation_index: u32 },
33+
PrivateKey { sr25519_secret_key: [u8; 64] },
34+
Coins { sr25519_secret_keys: Vec<[u8; 64]> },
35+
}
36+
```
37+
38+
Both `PrivateKey` and `Coins` now carry 64-byte Sr25519 secret keys. The `Ed25519PrivateKey` type is removed.
39+
40+
This is a **wire-breaking** change: the SCALE encoding of both variants changes length. All hosts and products must upgrade together within the same protocol version.

rust/crates/truapi/src/v01/payment.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ pub enum PaymentTopUpSource {
3939
/// Fund from a one-time account represented by its private key. This is a
4040
/// standard account holding public funds, not a coin key.
4141
PrivateKey {
42-
/// Ed25519 private key bytes.
43-
ed25519_private_key: [u8; 32],
42+
/// Sr25519 secret key bytes.
43+
sr25519_secret_key: [u8; 64],
4444
},
4545
/// Fund directly from coin secret keys. Each key is an sr25519 secret
4646
/// controlling a single coin.
4747
Coins {
4848
/// Sr25519 secret keys, one per coin.
49-
sr25519_secret_keys: Vec<[u8; 32]>,
49+
sr25519_secret_keys: Vec<[u8; 64]>,
5050
},
5151
}
5252

0 commit comments

Comments
 (0)