@twin.org/crypto 0.0.1-next.20 → 0.0.1-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +18 -0
- package/dist/esm/index.mjs +18 -0
- package/dist/types/address/bip44.d.ts +15 -0
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/Bip44.md +64 -0
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -592,6 +592,24 @@ class Bip44 {
|
|
|
592
592
|
static basePath(coinType) {
|
|
593
593
|
return `m/44'/${coinType}'`;
|
|
594
594
|
}
|
|
595
|
+
/**
|
|
596
|
+
* Generate an address from the seed and parts.
|
|
597
|
+
* @param seed The account seed.
|
|
598
|
+
* @param keyType The key type.
|
|
599
|
+
* @param coinType The coin type.
|
|
600
|
+
* @param accountIndex The account index.
|
|
601
|
+
* @param isInternal Is this an internal address.
|
|
602
|
+
* @param addressIndex The address index.
|
|
603
|
+
* @returns The generated path and the associated keypair.
|
|
604
|
+
*/
|
|
605
|
+
static address(seed, keyType, coinType, accountIndex, isInternal, addressIndex) {
|
|
606
|
+
const keyPair = Bip44.keyPair(seed, keyType, coinType, accountIndex, isInternal, addressIndex);
|
|
607
|
+
const addressData = Blake2b.sum256(keyPair.publicKey);
|
|
608
|
+
return {
|
|
609
|
+
address: core.Converter.bytesToHex(addressData, true),
|
|
610
|
+
...keyPair
|
|
611
|
+
};
|
|
612
|
+
}
|
|
595
613
|
/**
|
|
596
614
|
* Generate a bech32 address from the seed and parts.
|
|
597
615
|
* @param seed The account seed.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -570,6 +570,24 @@ class Bip44 {
|
|
|
570
570
|
static basePath(coinType) {
|
|
571
571
|
return `m/44'/${coinType}'`;
|
|
572
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Generate an address from the seed and parts.
|
|
575
|
+
* @param seed The account seed.
|
|
576
|
+
* @param keyType The key type.
|
|
577
|
+
* @param coinType The coin type.
|
|
578
|
+
* @param accountIndex The account index.
|
|
579
|
+
* @param isInternal Is this an internal address.
|
|
580
|
+
* @param addressIndex The address index.
|
|
581
|
+
* @returns The generated path and the associated keypair.
|
|
582
|
+
*/
|
|
583
|
+
static address(seed, keyType, coinType, accountIndex, isInternal, addressIndex) {
|
|
584
|
+
const keyPair = Bip44.keyPair(seed, keyType, coinType, accountIndex, isInternal, addressIndex);
|
|
585
|
+
const addressData = Blake2b.sum256(keyPair.publicKey);
|
|
586
|
+
return {
|
|
587
|
+
address: Converter.bytesToHex(addressData, true),
|
|
588
|
+
...keyPair
|
|
589
|
+
};
|
|
590
|
+
}
|
|
573
591
|
/**
|
|
574
592
|
* Generate a bech32 address from the seed and parts.
|
|
575
593
|
* @param seed The account seed.
|
|
@@ -34,6 +34,21 @@ export declare class Bip44 {
|
|
|
34
34
|
* @returns The bip44 address base path.
|
|
35
35
|
*/
|
|
36
36
|
static basePath(coinType: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Generate an address from the seed and parts.
|
|
39
|
+
* @param seed The account seed.
|
|
40
|
+
* @param keyType The key type.
|
|
41
|
+
* @param coinType The coin type.
|
|
42
|
+
* @param accountIndex The account index.
|
|
43
|
+
* @param isInternal Is this an internal address.
|
|
44
|
+
* @param addressIndex The address index.
|
|
45
|
+
* @returns The generated path and the associated keypair.
|
|
46
|
+
*/
|
|
47
|
+
static address(seed: Uint8Array, keyType: KeyType, coinType: number, accountIndex: number, isInternal: boolean, addressIndex: number): {
|
|
48
|
+
address: string;
|
|
49
|
+
privateKey: Uint8Array;
|
|
50
|
+
publicKey: Uint8Array;
|
|
51
|
+
};
|
|
37
52
|
/**
|
|
38
53
|
* Generate a bech32 address from the seed and parts.
|
|
39
54
|
* @param seed The account seed.
|
package/docs/changelog.md
CHANGED
|
@@ -140,6 +140,70 @@ The bip44 address base path.
|
|
|
140
140
|
|
|
141
141
|
***
|
|
142
142
|
|
|
143
|
+
### address()
|
|
144
|
+
|
|
145
|
+
> `static` **address**(`seed`, `keyType`, `coinType`, `accountIndex`, `isInternal`, `addressIndex`): `object`
|
|
146
|
+
|
|
147
|
+
Generate an address from the seed and parts.
|
|
148
|
+
|
|
149
|
+
#### Parameters
|
|
150
|
+
|
|
151
|
+
##### seed
|
|
152
|
+
|
|
153
|
+
`Uint8Array`
|
|
154
|
+
|
|
155
|
+
The account seed.
|
|
156
|
+
|
|
157
|
+
##### keyType
|
|
158
|
+
|
|
159
|
+
[`KeyType`](../type-aliases/KeyType.md)
|
|
160
|
+
|
|
161
|
+
The key type.
|
|
162
|
+
|
|
163
|
+
##### coinType
|
|
164
|
+
|
|
165
|
+
`number`
|
|
166
|
+
|
|
167
|
+
The coin type.
|
|
168
|
+
|
|
169
|
+
##### accountIndex
|
|
170
|
+
|
|
171
|
+
`number`
|
|
172
|
+
|
|
173
|
+
The account index.
|
|
174
|
+
|
|
175
|
+
##### isInternal
|
|
176
|
+
|
|
177
|
+
`boolean`
|
|
178
|
+
|
|
179
|
+
Is this an internal address.
|
|
180
|
+
|
|
181
|
+
##### addressIndex
|
|
182
|
+
|
|
183
|
+
`number`
|
|
184
|
+
|
|
185
|
+
The address index.
|
|
186
|
+
|
|
187
|
+
#### Returns
|
|
188
|
+
|
|
189
|
+
`object`
|
|
190
|
+
|
|
191
|
+
The generated path and the associated keypair.
|
|
192
|
+
|
|
193
|
+
##### address
|
|
194
|
+
|
|
195
|
+
> **address**: `string`
|
|
196
|
+
|
|
197
|
+
##### privateKey
|
|
198
|
+
|
|
199
|
+
> **privateKey**: `Uint8Array`
|
|
200
|
+
|
|
201
|
+
##### publicKey
|
|
202
|
+
|
|
203
|
+
> **publicKey**: `Uint8Array`
|
|
204
|
+
|
|
205
|
+
***
|
|
206
|
+
|
|
143
207
|
### addressBech32()
|
|
144
208
|
|
|
145
209
|
> `static` **addressBech32**(`seed`, `keyType`, `hrp`, `coinType`, `accountIndex`, `isInternal`, `addressIndex`): `object`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/crypto",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.21",
|
|
4
4
|
"description": "Contains helper methods and classes which implement cryptographic functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@scure/base": "1.2.1",
|
|
21
21
|
"@scure/bip32": "1.6.1",
|
|
22
22
|
"@scure/bip39": "1.5.1",
|
|
23
|
-
"@twin.org/core": "0.0.1-next.
|
|
23
|
+
"@twin.org/core": "0.0.1-next.21",
|
|
24
24
|
"@twin.org/nameof": "next",
|
|
25
25
|
"micro-key-producer": "0.7.3"
|
|
26
26
|
},
|