Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(psdk): update missing crypto classes (#95)
- Loading branch information
1 parent
2eee181
commit 31abd50
Showing
5 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: BIP32 | ||
--- | ||
|
||
# BIP32 | ||
|
||
The `BIP32` class provides methods to make derivation of hierarchical deterministic keys easier. | ||
|
||
### Importing the BIP32 class | ||
|
||
```typescript | ||
import { BIP32 } from "@arkecosystem/platform-sdk-crypto"; | ||
``` | ||
|
||
### Derive a key from a mnemonic | ||
|
||
```typescript | ||
BIP32.fromMnemonic('scout mushroom doctor prepare identify obvious soccer stage sudden already brass december million wish flower'); | ||
``` | ||
|
||
### Derive a key from a seed | ||
|
||
```typescript | ||
BIP32.fromSeed('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); | ||
``` | ||
|
||
### Derive a key from a base58 | ||
|
||
```typescript | ||
BIP32.fromBase58('xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi'); | ||
``` | ||
|
||
### Derive a key from a public key | ||
|
||
```typescript | ||
BIP32.fromPublicKey('xpub6FnCn6nSzZAw5Tw7cgR9bi15UV96gLZhjDstkXXxvCLsUXBGXPdSnLFbdpq8p9HmGsApME5hQTZ3emM2rnY5agb9rXpVGyy3bdW6EEgAtqt'); | ||
``` | ||
|
||
### Derive a key from a private key | ||
|
||
```typescript | ||
BIP32.fromPrivateKey('xprvA2nrNbFZABcdryreWet9Ea4LvTJcGsqrMzxHx98MMrotbir7yrKCEXw7nadnHM8Dq38EGfSh6dqA9QWTyefMLEcBYJUuekgW4BYPJcr9E7j'); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: HDKey | ||
--- | ||
|
||
# HDKey | ||
|
||
The `HDKey` class provides methods to make derivation of hierarchical deterministic keys easier. This class is similar to the `BIP32` class but provides some convenience methods for working with `xpub` and `xprv` values. | ||
|
||
### Importing the HDKey class | ||
|
||
```typescript | ||
import { HDKey } from "@arkecosystem/platform-sdk-crypto"; | ||
``` | ||
|
||
### Derive a key from a seed | ||
|
||
```typescript | ||
HDKey.fromSeed('a0c42a9c3ac6abf2ba6a9946ae83af18f51bf1c9fa7dacc4c92513cc4dd015834341c775dcd4c0fac73547c5662d81a9e9361a0aac604a73a321bd9103bce8af'); | ||
``` | ||
|
||
### Derive a key from an extended public key | ||
|
||
```typescript | ||
HDKey.fromExtendedPublicKey('xpub6FnCn6nSzZAw5Tw7cgR9bi15UV96gLZhjDstkXXxvCLsUXBGXPdSnLFbdpq8p9HmGsApME5hQTZ3emM2rnY5agb9rXpVGyy3bdW6EEgAtqt'); | ||
``` | ||
|
||
### Derive a key from an extended private key | ||
|
||
```typescript | ||
HDKey.fromExtendedPrivateKey('xprvA2nrNbFZABcdryreWet9Ea4LvTJcGsqrMzxHx98MMrotbir7yrKCEXw7nadnHM8Dq38EGfSh6dqA9QWTyefMLEcBYJUuekgW4BYPJcr9E7j'); | ||
``` | ||
|
||
### Derive a key from a compressed public key | ||
|
||
```typescript | ||
HDKey.fromCompressedPublicKey('fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542'); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: UUID | ||
--- | ||
|
||
# UUID | ||
|
||
The `UUID` class provides methods to make working with UUIDs easier and consistent across all Platform SDK products. | ||
|
||
### Importing the UUID class | ||
|
||
```typescript | ||
import { UUID } from "@arkecosystem/platform-sdk-crypto"; | ||
``` | ||
|
||
### Generate a UUID based on the current time | ||
|
||
```typescript | ||
UUID.timestamp(); | ||
``` | ||
|
||
### Generate a MD5 UUID based on a name and namespace | ||
|
||
```typescript | ||
UUID.md5('name', 'namespace'); | ||
``` | ||
|
||
### Generate a UUID based on a random value | ||
|
||
```typescript | ||
UUID.random(); | ||
``` | ||
|
||
### Generate a SHA1 UUID based on a name and namespace | ||
|
||
```typescript | ||
UUID.sha1('name', 'namespace'); | ||
``` | ||
|
||
### Generate a UUID based on a parse value | ||
|
||
```typescript | ||
UUID.parse('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'); | ||
``` | ||
|
||
### Convert a buffer into a UUID | ||
|
||
```typescript | ||
UUID.stringify(UUID.parse('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d')); | ||
``` | ||
|
||
### Validate a UUID | ||
|
||
```typescript | ||
UUID.validate('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: WIF | ||
--- | ||
|
||
# WIF | ||
|
||
The `WIF` class provides methods to make working with the `Bitcoin Wallet Import Format` easier and consistent across all Platform SDK products. | ||
|
||
### Importing the WIF class | ||
|
||
```typescript | ||
import { WIF } from "@arkecosystem/platform-sdk-crypto"; | ||
``` | ||
|
||
### Encode a private key | ||
|
||
```typescript | ||
WIF.encode({ | ||
version: 128, | ||
privateKey: "0000000000000000000000000000000000000000000000000000000000000001", | ||
compressed: true, | ||
}); | ||
``` | ||
|
||
### Decode an encoded WIF | ||
|
||
```typescript | ||
WIF.decode('KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn'); | ||
``` |