Skip to content

Commit

Permalink
chore(psdk): update missing crypto classes (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
faustbrian committed Apr 12, 2021
1 parent 2eee181 commit 31abd50
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/platform-sdk/crypto.md.blade.php
Expand Up @@ -24,12 +24,16 @@
['path' => '/docs/platform-sdk/crypto/argon2', 'name' => 'argon2'],
['path' => '/docs/platform-sdk/crypto/base64', 'name' => 'Base64'],
['path' => '/docs/platform-sdk/crypto/bcrypt', 'name' => 'bcrypt'],
['path' => '/docs/platform-sdk/crypto/bip32', 'name' => 'BIP32'],
['path' => '/docs/platform-sdk/crypto/bip38', 'name' => 'BIP38'],
['path' => '/docs/platform-sdk/crypto/bip39', 'name' => 'BIP39'],
['path' => '/docs/platform-sdk/crypto/bip44', 'name' => 'BIP44'],
['path' => '/docs/platform-sdk/crypto/hash', 'name' => 'Hash'],
['path' => '/docs/platform-sdk/crypto/hdkey', 'name' => 'HDKey'],
['path' => '/docs/platform-sdk/crypto/keychain', 'name' => 'Keychain'],
['path' => '/docs/platform-sdk/crypto/pbkdf2', 'name' => 'PBKDF2'],
['path' => '/docs/platform-sdk/crypto/uuid', 'name' => 'UUID'],
['path' => '/docs/platform-sdk/crypto/wif', 'name' => 'WIF'],
]"
/>

Expand Down
43 changes: 43 additions & 0 deletions docs/platform-sdk/crypto/bip32.md.blade.php
@@ -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');
```
37 changes: 37 additions & 0 deletions docs/platform-sdk/crypto/hdkey.md.blade.php
@@ -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');
```
55 changes: 55 additions & 0 deletions docs/platform-sdk/crypto/uuid.md.blade.php
@@ -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');
```
29 changes: 29 additions & 0 deletions docs/platform-sdk/crypto/wif.md.blade.php
@@ -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');
```

0 comments on commit 31abd50

Please sign in to comment.