Move Monero related classes to xmr package

This commit is contained in:
chimp1984 2022-05-26 23:42:30 +02:00
parent 69b1a0027b
commit 259b799ae6
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
23 changed files with 63 additions and 84 deletions

View File

@ -33,6 +33,7 @@ import bisq.core.trade.txproof.AssetTxProofResult;
import bisq.core.trade.txproof.AssetTxProofService;
import bisq.core.user.AutoConfirmSettings;
import bisq.core.user.Preferences;
import bisq.core.xmr.knaccc.monero.crypto.CryptoUtil;
import bisq.network.Socks5ProxyProvider;
import bisq.network.p2p.BootstrapListener;
@ -62,10 +63,6 @@ import lombok.extern.slf4j.Slf4j;
import static com.google.common.base.Preconditions.checkNotNull;
import knaccc.monero.crypto.CryptoUtil;
/**
* Entry point for clients to request tx proof and trigger auto-confirm if all conditions
* are met.

View File

@ -1,4 +1,4 @@
package com.joemelsha.crypto.hash;
package bisq.core.xmr.com.joemelsha.crypto.hash;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

View File

@ -1,4 +1,4 @@
package knaccc.monero.address;
package bisq.core.xmr.knaccc.monero.address;
import java.math.BigInteger;

View File

@ -1,4 +1,4 @@
package knaccc.monero.address;
package bisq.core.xmr.knaccc.monero.address;
import java.math.BigInteger;

View File

@ -1,18 +1,15 @@
package knaccc.monero.address;
package bisq.core.xmr.knaccc.monero.address;
import static knaccc.monero.address.ByteUtil.concat;
import static knaccc.monero.address.ByteUtil.hexToBytes;
import static knaccc.monero.address.ByteUtil.longToLittleEndianUint32ByteArray;
import static knaccc.monero.crypto.CryptoUtil.hashToScalar;
import bisq.core.xmr.knaccc.monero.crypto.CryptoUtil;
import bisq.core.xmr.knaccc.monero.crypto.Scalar;
import bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic.Ed25519EncodedFieldElement;
import bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic.Ed25519EncodedGroupElement;
import bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic.Ed25519Group;
import bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic.Ed25519GroupElement;
import knaccc.monero.crypto.CryptoUtil;
import knaccc.monero.crypto.Scalar;
import org.nem.core.crypto.ed25519.arithmetic.Ed25519EncodedFieldElement;
import org.nem.core.crypto.ed25519.arithmetic.Ed25519EncodedGroupElement;
import org.nem.core.crypto.ed25519.arithmetic.Ed25519Group;
import org.nem.core.crypto.ed25519.arithmetic.Ed25519GroupElement;
import static bisq.core.xmr.knaccc.monero.address.ByteUtil.concat;
import static bisq.core.xmr.knaccc.monero.address.ByteUtil.hexToBytes;
import static bisq.core.xmr.knaccc.monero.address.ByteUtil.longToLittleEndianUint32ByteArray;
public class WalletAddress {
@ -100,7 +97,7 @@ public class WalletAddress {
if (accountId == 0 && subaddressId == 0)
throw new RuntimeException("Not to be called for the base wallet address");
byte[] data = concat("SubAddr\0".getBytes(), privateViewKey.bytes, longToLittleEndianUint32ByteArray(accountId), longToLittleEndianUint32ByteArray(subaddressId));
Scalar m = hashToScalar(data);
Scalar m = CryptoUtil.hashToScalar(data);
Ed25519GroupElement M = G.scalarMultiply(new Ed25519EncodedFieldElement(m.bytes));
Ed25519GroupElement B = new Ed25519EncodedGroupElement(publicSpendKeyBytes).decode();
Ed25519GroupElement D = B.add(M.toCached());

View File

@ -1,18 +1,16 @@
package knaccc.monero.crypto;
package bisq.core.xmr.knaccc.monero.crypto;
import bisq.core.xmr.com.joemelsha.crypto.hash.Keccak;
import bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic.Ed25519Group;
import bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic.Ed25519GroupElement;
import bisq.core.xmr.org.nem.core.utils.HexEncoder;
import java.math.BigInteger;
import lombok.extern.slf4j.Slf4j;
import static knaccc.monero.address.ByteUtil.getBigIntegerFromUnsignedLittleEndianByteArray;
import static knaccc.monero.address.ByteUtil.reverseByteArrayInPlace;
import com.joemelsha.crypto.hash.Keccak;
import org.nem.core.crypto.ed25519.arithmetic.Ed25519Group;
import org.nem.core.crypto.ed25519.arithmetic.Ed25519GroupElement;
import org.nem.core.utils.HexEncoder;
import static bisq.core.xmr.knaccc.monero.address.ByteUtil.getBigIntegerFromUnsignedLittleEndianByteArray;
import static bisq.core.xmr.knaccc.monero.address.ByteUtil.reverseByteArrayInPlace;
@Slf4j
public class CryptoUtil {

View File

@ -1,15 +1,13 @@
package knaccc.monero.crypto;
package bisq.core.xmr.knaccc.monero.crypto;
import bisq.core.xmr.knaccc.monero.address.ByteUtil;
import java.util.Arrays;
import static knaccc.monero.address.ByteUtil.bytesToHex;
import static knaccc.monero.address.ByteUtil.getBigIntegerFromUnsignedLittleEndianByteArray;
import static knaccc.monero.crypto.CryptoUtil.ensure32BytesAndConvertToLittleEndian;
import static knaccc.monero.crypto.CryptoUtil.l;
import knaccc.monero.address.ByteUtil;
import static bisq.core.xmr.knaccc.monero.address.ByteUtil.bytesToHex;
import static bisq.core.xmr.knaccc.monero.address.ByteUtil.getBigIntegerFromUnsignedLittleEndianByteArray;
import static bisq.core.xmr.knaccc.monero.crypto.CryptoUtil.ensure32BytesAndConvertToLittleEndian;
import static bisq.core.xmr.knaccc.monero.crypto.CryptoUtil.l;
public class Scalar {

View File

@ -1,4 +1,4 @@
package org.nem.core.crypto;
package bisq.core.xmr.org.nem.core.crypto;
import java.math.BigInteger;

View File

@ -1,15 +1,14 @@
package org.nem.core.crypto.ed25519;
package bisq.core.xmr.org.nem.core.crypto.ed25519;
import bisq.core.xmr.org.nem.core.crypto.Curve;
import bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic.Ed25519Group;
import java.math.BigInteger;
import org.nem.core.crypto.ed25519.arithmetic.Ed25519Group;
/**
* Class that wraps the elliptic curve Ed25519.
*/
public class Ed25519Curve implements org.nem.core.crypto.Curve {
public class Ed25519Curve implements Curve {
private static final Ed25519Curve ED25519;

View File

@ -1,4 +1,4 @@
package org.nem.core.crypto.ed25519.arithmetic;
package bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic;
/**
* Available coordinate systems for a group element.

View File

@ -1,12 +1,10 @@
package org.nem.core.crypto.ed25519.arithmetic;
package bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic;
import bisq.core.xmr.org.nem.core.utils.ArrayUtils;
import bisq.core.xmr.org.nem.core.utils.HexEncoder;
import java.util.Arrays;
import org.nem.core.utils.ArrayUtils;
import org.nem.core.utils.HexEncoder;
/**
* Represents a field element of the finite field with p=2^255-19 elements.
* The value of the field element is held in 2^8 bit representation, i.e. in a byte array.

View File

@ -1,11 +1,9 @@
package org.nem.core.crypto.ed25519.arithmetic;
package bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic;
import bisq.core.xmr.org.nem.core.utils.ArrayUtils;
import java.util.Arrays;
import org.nem.core.utils.ArrayUtils;
public class Ed25519EncodedGroupElement {
private final byte[] values;

View File

@ -1,12 +1,10 @@
package org.nem.core.crypto.ed25519.arithmetic;
package bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic;
import bisq.core.xmr.org.nem.core.utils.ArrayUtils;
import bisq.core.xmr.org.nem.core.utils.HexEncoder;
import java.math.BigInteger;
import org.nem.core.utils.ArrayUtils;
import org.nem.core.utils.HexEncoder;
/**
* Represents the underlying finite field for Ed25519.
* The field has p = 2^255 - 19 elements.

View File

@ -1,4 +1,4 @@
package org.nem.core.crypto.ed25519.arithmetic;
package bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic;
import java.util.Arrays;

View File

@ -1,11 +1,9 @@
package org.nem.core.crypto.ed25519.arithmetic;
package bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic;
import bisq.core.xmr.org.nem.core.utils.HexEncoder;
import java.math.BigInteger;
import org.nem.core.utils.HexEncoder;
/**
* Represents the underlying group for Ed25519.
*/

View File

@ -1,11 +1,9 @@
package org.nem.core.crypto.ed25519.arithmetic;
package bisq.core.xmr.org.nem.core.crypto.ed25519.arithmetic;
import bisq.core.xmr.org.nem.core.utils.ByteUtils;
import java.io.Serializable;
import org.nem.core.utils.ByteUtils;
/**
* A point on the ED25519 curve which represents a group element.
* This implementation is based on the ref10 implementation of SUPERCOP.

View File

@ -1,4 +1,4 @@
package org.nem.core.utils;
package bisq.core.xmr.org.nem.core.utils;
import java.math.BigInteger;

View File

@ -1,4 +1,4 @@
package org.nem.core.utils;
package bisq.core.xmr.org.nem.core.utils;
import java.nio.ByteBuffer;

View File

@ -1,6 +1,6 @@
package org.nem.core.utils;
package bisq.core.xmr.org.nem.core.utils;
import knaccc.monero.address.ByteUtil;
import bisq.core.xmr.knaccc.monero.address.ByteUtil;
// modified to not rely on apache commons

View File

@ -17,15 +17,13 @@
package knaccc.monero.address;
import bisq.core.xmr.knaccc.monero.crypto.CryptoUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import knaccc.monero.crypto.CryptoUtil;
public class CryptoUtilTest {
@Test
public void testWalletAddress() {

View File

@ -17,6 +17,8 @@
package knaccc.monero.address;
import bisq.core.xmr.knaccc.monero.address.WalletAddress;
import org.junit.Test;
import static org.junit.Assert.assertEquals;