Skip to content

Commit

Permalink
Merge branch 'master' into fix/#59
Browse files Browse the repository at this point in the history
  • Loading branch information
sneurlax committed Apr 2, 2018
2 parents 9b14237 + 4e45eb4 commit ff28036
Show file tree
Hide file tree
Showing 10 changed files with 2,484 additions and 416 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,31 @@ In addition to these features, there are other lower-level libraries included fo
## Preview
![Preview](https://user-images.githubusercontent.com/4107993/38056594-b6cd6e14-3291-11e8-96e2-a771b0e9cee3.png)

## Documention

Documentation can be found in the [`/docs`](https://github.com/sneurlax/monerophp/tree/master/docs) folder.

## Configuration
### Requirements
- Monero daemon
- Monero daemon (`monerod`)
- Webserver with PHP, for example XMPP, Apache, or NGINX
- cURL PHP extension for JSON RPC API(s)
- GMP PHP extension for about 100x faster calculations (as opposed to BCMath)

Debian (or Ubuntu) are recommended.

---
### Getting Started

1. Start the Monero daemon (`monerod`) on testnet
1. Start the Monero daemon (`monerod`) on testnet.
```bash
monerod --testnet --detach
```

2. Start the Monero wallet RPC interface (`monero-wallet-rpc`) on testnet
2. Start the Monero wallet RPC interface (`monero-wallet-rpc`) on testnet.
```bash
monero-wallet-rpc --testnet --rpc-bind-port 28083 --disable-rpc-login --wallet-dir /path/to/wallet/directory
```

3. Edit `example.php` with your the IP address of `monerod` and `monero-wallet-rpc` (use `127.0.0.1:28081` and `127.0.0.1:28083`, respectively, for testnet)
3. Edit `example.php` with your the IP address of `monerod` and `monero-wallet-rpc` (use `127.0.0.1:28081` and `127.0.0.1:28083`, respectively, for testnet.)

4. Open your browser with your IP address of local webserver (*eg.* XMPP, Apache/Apache2, NGINX, *etc.*) and execute example.php. If everything has been set up correctly, information from your Monero daemon and wallet will be displayed.
4. Serve `example.php` with your webserver (*eg.* XMPP, Apache/Apache2, NGINX, *etc.*) and navigate to it. If everything has been set up correctly, information from your Monero daemon and wallet will be displayed.
166 changes: 166 additions & 0 deletions docs/README.md

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions docs/base58.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# `base58` class

[`src/base58.php`](https://github.com/monero-integrations/monerophp/tree/master/src/base58.php)

A PHP Base58 codec

### Methods

- [`encode`](#encode)
- [`decode`](#decode)

#### `encode`

Encode a hexadecimal (Base16) string to Base58

Parameters:

- `$hex <String>` A hexadecimal (Base16) string to convert to Base58

Return: `<String>`

`"479cG5opa54beQWSyqNoWw5tna9sHUNmMTtiFqLPaUhDevpJ2YLwXAggSx5ePdeFrYF8cdbmVRSmp1Kn3t4Y9kFu7rZ7pFw"`

#### `decode`

Decode a Base58 string to hexadecimal (Base16)

Parameters:

- `$hex <String>` A Base58 string to convert to hexadecimal (Base16)

Return: `<String>`

`"0137F8F06C971B168745F562AA107B4D172F336271BC0F9D3B510C14D3460DFB27D8CEBE561E73AC1E11833D5EA40200EB3C82E9C66ACAF1AB1A6BB53C40537C0B7A22160B0E"`

### Credits

Written by the [Monero Integrations team](https://github.com/monero-integrations/monerophp/graphs/contributors) (<support@monerointegrations.com>)

Using work from:
- bigreddmachine [MoneroPy] (https://github.com/bigreddmachine)
- Paul Shapiro [mymonero-core-js] (https://github.com/paulshapiro)
246 changes: 246 additions & 0 deletions docs/cryptonote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
# `cryptonote` class

[`src/cryptonote.php`](https://github.com/monero-integrations/monerophp/tree/master/src/cryptonote.php)

### Methods

- [`keccak_256`](#keccak_256)
- [`gen_new_hex_seed`](#gen_new_hex_seed)
- [`sc_reduce`](#sc_reduce)
- [`hash_to_scalar`](#hash_to_scalar)
- [`derive_viewKey`](#derive_viewKey)
- [`gen_private_keys`](#gen_private_keys)
- [`pk_from_sk`](#pk_from_sk)
- [`gen_key_derivation`](#gen_key_derivation)
- [`encode_varint`](#encode_varint)
- [`derivation_to_scalar`](#derivation_to_scalar)
- [`stealth_payment_id`](#stealth_payment_id)
- [`txpub_from_extra`](#txpub_from_extra)
- [`derive_public_key`](#derive_public_key)
- [`is_output_mine`](#is_output_mine)
- [`encode_address`](#encode_address)
- [`verify_checksum`](#verify_checksum)
- [`decode_address`](#decode_address)
- [`integrated_addr_from_keys`](#integrated_addr_from_keys)
- [`address_from_seed`](#address_from_seed)

#### `keccak_256`

Derive a Keccak256 hash from a string

Parameters:

- `$message <String>` Hex encoded string of the data to hash

Return: `<String>` Hex encoded string of the hashed data

[//]: # (TODO example)

#### `gen_new_hex_seed`

Generate a hexadecimal seed

Return: `<String>` A hex encoded string of 32 random bytes

[//]: # (TODO example)

#### `sc_reduce`

Parameters:

- `$input <String>`

[//]: # (TODO return type and example)

#### `hash_to_scalar`

`Hs` in the cryptonote white paper

Parameters:

- `$data <String>` Hex encoded data to hash

Return: `<String>` A 32 byte encoded integer

[//]: # (TODO example)

#### `derive_viewKey`

Derive a deterministic private view key from a private spend key

Parameters:

- `$spendKey <String>` A deterministic private view key represented as a 32 byte hex string

Return: `<String>`

[//]: # (TODO example)

#### `gen_private_keys`

Generate a pair of random private keys

Parameters:

- `$seed <String>` A hex string to be used as a seed (this should be random)

Return: `<Array>` An array containing a private spend key and a deterministic view key

[//]: # (TODO example)

#### `pk_from_sk`

Get a public key from a private key on the ed25519 curve

Parameters:

- `$privKey <String>` A 32 byte hex encoded private key

Return: `<String>`

[//]: # (TODO example)

#### `gen_key_derivation`

Generate key derivation

Parameters:

- `$public <String>` a 32 byte hex encoding of a point on the ed25519 curve used as a public key
- `$private <String>` a 32 byte hex encoded private key

Return: `<String>` The hex encoded key derivation

[//]: # (TODO example)

#### `encode_varint`

Parameters:

- `$der <>`
- `$index <>`

[//]: # (TODO return type and example)

#### `derivation_to_scalar`

Parameters:

- `$ <>`

[//]: # (TODO return type and example)

#### `stealth_payment_id`

A one way function used for both encrypting and decrypting 8 byte payment IDs

Parameters:

- `$payment_id <String>`
- `$tx_pub_key <String>`
- `$viewkey <String>`

Return: `<String>`

[//]: # (TODO example)

#### `txpub_from_extra`

Takes transaction extra field as hex string and returns transaction public key 'R' as hex string

Parameters:

- `$extra <String>`

Return: `<String>`

[//]: # (TODO example)

#### `derive_public_key`

Parameters:

- `$der <>`
- `$index <>`
- `$pub <>`

Return: `<String>`

[//]: # (TODO example)

#### `is_output_mine`

Perform the calculation P = P' as described in the cryptonote whitepaper

Parameters:

- `$txPublic <String>` 32 byte transaction public key R
- `$privViewkey <String>` 32 byte reciever private view key a
- `$publicSpendkey <String>` 32 byte reciever public spend key B
- `$index <Number>` Otput index
- `$P <String>` Output you want to check against P

Return: `<Boolean>`

[//]: # (TODO example)

#### `encode_address`

Create a valid base58 encoded Monero address from public keys

Parameters:

- `$pSpendKey <String>` Public spend key
- `$pViewKey <String>` Public view key

Return: `<String>` Base58 encoded Monero address

[//]: # (TODO example)

#### `verify_checksum`

Parameters:

- `$address <>`

Return: `<Boolean>`

[//]: # (TODO example)

#### `decode_address`

Decode a base58 encoded Monero address

Parameters:

- `$address <String>` A base58 encoded Monero address

Return: `<Array>` An array containing the Address network byte, public spend key, and public view key
[//]: # (TODO example)


#### `integrated_addr_from_keys`

Create an integrated address from public keys and a payment ID

Parameters:

- `$public_spendkey <String>` A 32 byte hex encoded public spend key
- `$public_viewkey <String>` A 32 byte hex encoded public view key
- `$payment_id <String>` An 8 byte hex string to use as a payment id

Return: `<String>` Integrated address

[//]: # (TODO example)

#### `address_from_seed`

Derive Monero address from seed

Parameters:

- `$hex_seed <String>` Hex string to use as seed

Return: `<String>` A base58 encoded Monero address

[//]: # (TODO example)

0 comments on commit ff28036

Please sign in to comment.