Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: Final touches (closes #147, #135, #133, #132, #124, #111, #100, #92, #82, #81, #57, #54) #154

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2480131
chore: remove deprecated classes
recanman May 2, 2024
2c8311e
chore: remove old example.php
recanman May 2, 2024
5e417b6
style: format files
recanman May 2, 2024
ac1513f
feat: rename library, bump php, add phpunit test support
recanman May 2, 2024
612c909
feat: add new Mnemonic class
recanman May 2, 2024
ea70d6d
ci: add security and test workflows
recanman May 2, 2024
32702a5
feat: partially-refactored varint class and tests
recanman May 2, 2024
dc74c82
chore: delete old base58 class
recanman May 9, 2024
4eead4b
feat: implement base58 encode and tests
recanman May 9, 2024
95d72fc
docs: block comments for Base58
recanman May 9, 2024
1a699c7
feat: implement Monero base58 decode
recanman May 9, 2024
d374296
fix: use base58 static methods in Cryptonote, set namespace
recanman May 9, 2024
0b269e5
feat: add some Cryptonote tests
recanman May 16, 2024
793f73e
feat: BigInt, use it in base58
recanman May 16, 2024
1c89c99
chore: improve composer.json gmp suggestion msg
recanman May 16, 2024
5f5eecc
docs: grammatical error in comment
recanman May 16, 2024
6bbbac1
feat: add tests for BigInteger class
recanman May 16, 2024
69b9a6f
ci: add release action
recanman May 25, 2024
461773f
docs: add documentation on publishing
recanman May 25, 2024
2d5d318
ci: change main to master
recanman May 25, 2024
873fdb0
fix: allow mixed input to various BigInteger functions
recanman May 27, 2024
9b05ea7
chore: remove ext-curl dependency
recanman May 27, 2024
cfb4d06
feat: BigInteger bitshift left and right
recanman May 27, 2024
8b9bf27
feat: add bitshift left/right to BigInteger
recanman Jun 1, 2024
51a0bf9
feat: partially implement new ed25519 class
recanman Jun 1, 2024
c9273b7
chore: delete redundant subaddress class
recanman Jun 1, 2024
5d9a8f4
chore: delete old ed25519 class
recanman Jun 1, 2024
457ab44
feat: MoneroNetwork enum in Cryptonote, declare strict types
recanman Jun 1, 2024
95b081c
fix: declare Cryptonote type in test
recanman Jun 1, 2024
8db754c
chore: comment out failing Cryptonote tests until functions fixed (te…
recanman Jun 1, 2024
4945605
feat: accept MoneroNetwork enum in Cryptonote constructor
recanman Jun 1, 2024
87497ea
feat: implement Ed25519 point encoding
recanman Jun 2, 2024
a7b9059
test: add another point test
recanman Jun 2, 2024
a76b1ab
feat: implement bit and decodepoint
recanman Jun 2, 2024
f0a0e6a
chore: remove unused parameter
recanman Jun 2, 2024
54f8d73
chore: fix wordset docstrings
recanman Jun 2, 2024
b4db214
chore: fix many phpstan errors
recanman Jun 2, 2024
40d5f0a
test: add negative base58 test
recanman Jun 2, 2024
04e86f1
test: edwards and scalarmult test, formatting
recanman Jun 5, 2024
2e1d826
fix: edwards implementation
recanman Jun 5, 2024
b6f49d2
fix: don't convert to int in bit
recanman Jun 5, 2024
f732277
fix: decodepoint
recanman Jun 5, 2024
002394c
test: ed25519 public key
recanman Jun 5, 2024
114fbaa
test: sc_reduce
recanman Jun 5, 2024
43f11ad
fix: duplicate declaration of network_prefixes
recanman Aug 3, 2024
b2831a5
style: add editorconfig and format files
recanman Aug 3, 2024
8611a82
refactor: use new classes and clean up cryptonote code
recanman Aug 3, 2024
b2d91ab
chore: remove unneeded extension
recanman Aug 3, 2024
40031d0
docs: rewrite readme
recanman Aug 3, 2024
d3d8223
docs: add mnemonic.md
recanman Aug 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style: format files
  • Loading branch information
recanman committed May 2, 2024
commit 5e417b686be4cca6c47e265790b183fe896ee68c
537 changes: 266 additions & 271 deletions src/Cryptonote.php

Large diffs are not rendered by default.

130 changes: 64 additions & 66 deletions src/Varint.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,79 +22,77 @@
*/
namespace MoneroIntegrations\MoneroPhp;

class Varint
class Varint
{
public function encode_varint($data)
{
public function encode_varint($data)
{
$orig = $data;
$orig = $data;

if ($data < 0x80)
{
return bin2hex(pack('C', $data));
}
if ($data < 0x80) {
return bin2hex(pack('C', $data));
}

$encodedBytes = [];
while ($data > 0) {
$encodedBytes[] = 0x80 | ($data & 0x7f);
$data >>= 7;
}

$encodedBytes[count($encodedBytes) - 1] &= 0x7f;
$bytes = call_user_func_array('pack', array_merge(array('C*'), $encodedBytes));
;
return bin2hex($bytes);
}

// https://github.com/monero-project/research-lab/blob/master/source-code/StringCT-java/src/how/monero/hodl/util/VarInt.java
public function decode_varint($data)
{
$result = 0;
$c = 0;
$pos = 0;

$encodedBytes = [];
while ($data > 0)
{
$encodedBytes[] = 0x80 | ($data & 0x7f);
$data >>= 7;
while (true) {
$isLastByteInVarInt = true;
$i = hexdec($data[$pos]);
if ($i >= 128) {
$isLastByteInVarInt = false;
$i -= 128;
}
$result += ($i * (pow(128, $c)));
$c += 1;
$pos += 1;

$encodedBytes[count($encodedBytes)-1] &= 0x7f;
$bytes = call_user_func_array('pack', array_merge(array('C*'), $encodedBytes));;
return bin2hex($bytes);
}

// https://github.com/monero-project/research-lab/blob/master/source-code/StringCT-java/src/how/monero/hodl/util/VarInt.java
public function decode_varint($data)
{
$result = 0;
$c = 0;
$pos = 0;

while (true)
{
$isLastByteInVarInt = true;
$i = hexdec($data[$pos]);
if ($i >= 128)
{
$isLastByteInVarInt = false;
$i -= 128;
}
$result += ($i * (pow(128, $c)));
$c += 1;
$pos += 1;

if ($isLastByteInVarInt)
break;
if ($isLastByteInVarInt) {
break;
}
return $result;
}

public function pop_varint($data)
{
$result = 0;
$c = 0;
$pos = 0;
while (true)
{
$isLastByteInVarInt = true;
$i = hexdec($data[$pos]);
if ($i >= 128)
{
$isLastByteInVarInt = false;
$i -= 128;
}
$result += ($i * (pow(128, $c)));
$c += 1;
$pos += 1;
if ($isLastByteInVarInt)
break;
return $result;
}

public function pop_varint($data)
{
$result = 0;
$c = 0;
$pos = 0;

while (true) {
$isLastByteInVarInt = true;
$i = hexdec($data[$pos]);
if ($i >= 128) {
$isLastByteInVarInt = false;
$i -= 128;
}
$result += ($i * (pow(128, $c)));
$c += 1;
$pos += 1;

if ($isLastByteInVarInt) {
break;
}
for ($x = 0; $x < $pos; $x++)
array_shift($data);
return $data;
}
for ($x = 0; $x < $pos; $x++) {
array_shift($data);
}
return $data;
}
}
Loading