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

Enclave public key length constraint removed for private transactions #4086

Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
149f7d1
removed constraint with the length of the privacy public key
freemanzMrojo May 9, 2022
8025037
refactor to include tessera ec encryptor
freemanzMrojo May 9, 2022
441ac5f
refactor to include tessera ec encryptor
freemanzMrojo May 9, 2022
f9240fc
added ec keys
freemanzMrojo May 9, 2022
ebf2c9d
added EC snippet to the tessera json config, still need to replace ba…
freemanzMrojo May 9, 2022
3cfd573
acceptance tests working after modifying the web3j library to allow s…
freemanzMrojo May 10, 2022
37acb79
acceptance tests working after modifying the web3j library to allow s…
freemanzMrojo May 10, 2022
6d46da3
acceptance tests working after modifying the web3j library to allow s…
freemanzMrojo May 10, 2022
5eaa5e5
added ec encryptor for multitenancy
freemanzMrojo May 11, 2022
61256cd
encoding of privacy users modified to allow secp256r1 ones
freemanzMrojo May 11, 2022
208e7a7
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo May 31, 2022
106dd30
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jun 2, 2022
3e9c0d4
reverted flexible privacy tests
freemanzMrojo Jun 2, 2022
a318227
spotless
freemanzMrojo Jun 2, 2022
a971984
using NACL encryptor by default
freemanzMrojo Jun 2, 2022
169f498
using 4.9.2 for base64string, to be removed
freemanzMrojo Jun 7, 2022
f54e7ce
privacyaccountresolver refactored
freemanzMrojo Jun 7, 2022
175dc2d
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jun 7, 2022
90a1275
fixed enclave error acceptance test
freemanzMrojo Jun 9, 2022
223c39d
fixed enclave error acceptance test
freemanzMrojo Jun 9, 2022
113f705
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jun 9, 2022
b2bdd01
added enclave encryptor type parameter to plugin privacy acceptance test
freemanzMrojo Jun 10, 2022
5dff1c5
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jun 10, 2022
161385e
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jun 13, 2022
d69b9ed
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jun 14, 2022
d9dfbb3
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jun 17, 2022
5c21819
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jun 30, 2022
2a77adf
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jul 5, 2022
ef10fd3
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jul 11, 2022
8fe8319
using web3j.eea 4.9.3 version
freemanzMrojo Jul 12, 2022
d6090eb
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 12, 2022
7e67e27
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 13, 2022
a8e36d6
Merge branch 'main' into privacy-pubkey-length-constraint-removed
antonydenyer Jul 15, 2022
b8368d1
Merge branch 'hyperledger:main' into privacy-pubkey-length-constraint…
freemanzMrojo Jul 21, 2022
6bf26e2
using web3j v4.9.4 and web3j-quorum v4.9.0
freemanzMrojo Jul 21, 2022
1c874c5
fixed container tests
freemanzMrojo Jul 21, 2022
83fcfd5
fixed clique acceptance test
freemanzMrojo Jul 21, 2022
622d33e
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 22, 2022
87c9d0b
small change
freemanzMrojo Jul 22, 2022
94861e7
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 25, 2022
c561d86
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 26, 2022
4d7960f
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 26, 2022
d8c7aa7
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 26, 2022
b687aac
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 26, 2022
15768e3
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 27, 2022
76eaa30
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Jul 28, 2022
e7ed6bd
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Aug 3, 2022
7000974
Merge branch 'main' of github.com:freemanzMrojo/besu into privacy-pub…
freemanzMrojo Aug 4, 2022
ef2b8f3
reverted change made to make the tests work along with web3j v4.9.4
freemanzMrojo Aug 4, 2022
fa0ae25
reverted change made to make the tests work along with web3j v4.9.4
freemanzMrojo Aug 4, 2022
3f6ae06
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Aug 5, 2022
d38afbf
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Aug 6, 2022
cab7c80
Merge branch 'main' into privacy-pubkey-length-constraint-removed
freemanzMrojo Aug 8, 2022
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
1 change: 1 addition & 0 deletions acceptance-tests/dsl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies {
implementation 'org.web3j:abi'
implementation 'org.web3j:besu'
implementation 'org.web3j:crypto'
implementation 'org.web3j:eea'

implementation 'org.testcontainers:testcontainers'
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ public PrivacyNode create(
return new PrivacyNode(privacyNodeConfig, vertx, enclaveType, containerNetwork);
}

public PrivacyNode createPrivateTransactionEnabledMinerNode(
final String name,
final PrivacyAccount privacyAccount,
final EnclaveType enclaveType,
final Optional<Network> containerNetwork)
throws IOException {
return createPrivateTransactionEnabledMinerNode(
name, privacyAccount, enclaveType, containerNetwork, false, false, false);
}

public PrivacyNode createPrivateTransactionEnabledMinerNode(
final String name,
final PrivacyAccount privacyAccount,
Expand All @@ -83,21 +73,13 @@ public PrivacyNode createPrivateTransactionEnabledMinerNode(
.extraCLIOptions(List.of("--plugin-privacy-service-encryption-prefix=0xAA"))
.build(),
new EnclaveKeyConfiguration(
privacyAccount.getEnclaveKeyPaths(), privacyAccount.getEnclavePrivateKeyPaths())),
privacyAccount.getEnclaveKeyPaths(),
privacyAccount.getEnclavePrivateKeyPaths(),
privacyAccount.getEnclaveEncryptorType())),
enclaveType,
containerNetwork);
}

public PrivacyNode createPrivateTransactionEnabledNode(
final String name,
final PrivacyAccount privacyAccount,
final EnclaveType enclaveType,
final Optional<Network> containerNetwork)
throws IOException {
return createPrivateTransactionEnabledNode(
name, privacyAccount, enclaveType, containerNetwork, false, false, false);
}

public PrivacyNode createPrivateTransactionEnabledNode(
final String name,
final PrivacyAccount privacyAccount,
Expand All @@ -122,21 +104,13 @@ public PrivacyNode createPrivateTransactionEnabledNode(
.extraCLIOptions(List.of("--plugin-privacy-service-encryption-prefix=0xBB"))
.build(),
new EnclaveKeyConfiguration(
privacyAccount.getEnclaveKeyPaths(), privacyAccount.getEnclavePrivateKeyPaths())),
privacyAccount.getEnclaveKeyPaths(),
privacyAccount.getEnclavePrivateKeyPaths(),
privacyAccount.getEnclaveEncryptorType())),
enclaveType,
containerNetwork);
}

public PrivacyNode createIbft2NodePrivacyEnabled(
final String name,
final PrivacyAccount privacyAccount,
final EnclaveType enclaveType,
final Optional<Network> containerNetwork)
throws IOException {
return createIbft2NodePrivacyEnabled(
name, privacyAccount, false, enclaveType, containerNetwork, false, false, false, "0xAA");
}

public PrivacyNode createIbft2NodePrivacyEnabled(
final String name,
final PrivacyAccount privacyAccount,
Expand Down Expand Up @@ -167,7 +141,9 @@ public PrivacyNode createIbft2NodePrivacyEnabled(
List.of("--plugin-privacy-service-encryption-prefix=" + unrestrictedPrefix))
.build(),
new EnclaveKeyConfiguration(
privacyAccount.getEnclaveKeyPaths(), privacyAccount.getEnclavePrivateKeyPaths())),
privacyAccount.getEnclaveKeyPaths(),
privacyAccount.getEnclavePrivateKeyPaths(),
privacyAccount.getEnclaveEncryptorType())),
enclaveType,
containerNetwork);
}
Expand Down Expand Up @@ -204,7 +180,9 @@ public PrivacyNode createIbft2NodePrivacyEnabledWithGenesis(
"--plugin-privacy-service-genesis-enabled=true"))
.build(),
new EnclaveKeyConfiguration(
privacyAccount.getEnclaveKeyPaths(), privacyAccount.getEnclavePrivateKeyPaths())),
privacyAccount.getEnclaveKeyPaths(),
privacyAccount.getEnclavePrivateKeyPaths(),
privacyAccount.getEnclaveEncryptorType())),
enclaveType,
containerNetwork);
}
Expand Down Expand Up @@ -238,7 +216,9 @@ public PrivacyNode createQbftNodePrivacyEnabled(
List.of("--plugin-privacy-service-encryption-prefix=" + unrestrictedPrefix))
.build(),
new EnclaveKeyConfiguration(
privacyAccount.getEnclaveKeyPaths(), privacyAccount.getEnclavePrivateKeyPaths())),
privacyAccount.getEnclaveKeyPaths(),
privacyAccount.getEnclavePrivateKeyPaths(),
privacyAccount.getEnclaveEncryptorType())),
enclaveType,
containerNetwork);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package org.hyperledger.besu.tests.acceptance.dsl.privacy;

import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.EC;
import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.NACL;
import static org.hyperledger.enclave.testutil.EnclaveType.NOOP;
import static org.hyperledger.enclave.testutil.EnclaveType.TESSERA;
import static org.web3j.utils.Restriction.RESTRICTED;
Expand All @@ -22,6 +24,7 @@
import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.PluginCreateRandomPrivacyGroupIdTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.RestrictedCreatePrivacyGroupTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction;
import org.hyperledger.enclave.testutil.EnclaveEncryptorType;
import org.hyperledger.enclave.testutil.EnclaveType;

import java.util.Arrays;
Expand All @@ -36,19 +39,24 @@
public abstract class ParameterizedEnclaveTestBase extends PrivacyAcceptanceTestBase {
protected final Restriction restriction;
protected final EnclaveType enclaveType;
protected final EnclaveEncryptorType enclaveEncryptorType;

protected ParameterizedEnclaveTestBase(
final Restriction restriction, final EnclaveType enclaveType) {
final Restriction restriction,
final EnclaveType enclaveType,
final EnclaveEncryptorType enclaveEncryptorType) {
this.restriction = restriction;
this.enclaveType = enclaveType;
this.enclaveEncryptorType = enclaveEncryptorType;
}

@Parameters(name = "{0} tx with {1} enclave")
@Parameters(name = "{0} tx with {1} enclave and {2} encryptor type")
public static Collection<Object[]> params() {
return Arrays.asList(
new Object[][] {
{RESTRICTED, TESSERA},
{UNRESTRICTED, NOOP}
{RESTRICTED, TESSERA, NACL},
{RESTRICTED, TESSERA, EC},
{UNRESTRICTED, NOOP, EnclaveEncryptorType.NOOP}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.hyperledger.besu.tests.acceptance.dsl.condition.net.NetConditions;
import org.hyperledger.besu.tests.acceptance.dsl.condition.priv.PrivConditions;
import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.privacy.PrivacyNodeFactory;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.account.PrivacyAccountResolver;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.PrivateContractVerifier;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.PrivateTransactionVerifier;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.contract.PrivateContractTransactions;
Expand All @@ -47,7 +46,6 @@ public class PrivacyAcceptanceTestBase {
protected final PrivateContractTransactions privateContractTransactions;
protected final PrivConditions priv;
protected final PrivacyCluster privacyCluster;
protected final PrivacyAccountResolver privacyAccountResolver;
protected final ContractTransactions contractTransactions;
protected final NetConditions net;
protected final EthTransactions ethTransactions;
Expand All @@ -63,7 +61,6 @@ public PrivacyAcceptanceTestBase() {
privacyBesu = new PrivacyNodeFactory(vertx);
privateContractTransactions = new PrivateContractTransactions();
privacyCluster = new PrivacyCluster(net);
privacyAccountResolver = new PrivacyAccountResolver();
priv =
new PrivConditions(
new org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package org.hyperledger.besu.tests.acceptance.dsl.privacy.account;

import org.hyperledger.enclave.testutil.EnclaveEncryptorType;

import java.io.File;
import java.net.URL;
import java.util.Arrays;
Expand All @@ -23,27 +25,38 @@ public class PrivacyAccount {
private final URL privateKeyPath;
private final URL[] enclaveKeyPaths;
private final URL[] enclavePrivateKeyPaths;
private final EnclaveEncryptorType enclaveEncryptorType;

private PrivacyAccount(
final URL privateKeyPath,
final URL[] enclavePublicKeyPaths,
final URL[] enclavePrivateKeyPaths) {
final URL[] enclavePrivateKeyPaths,
final EnclaveEncryptorType enclaveEncryptorType) {
this.privateKeyPath = privateKeyPath;
this.enclaveKeyPaths = enclavePublicKeyPaths;
this.enclavePrivateKeyPaths = enclavePrivateKeyPaths;
this.enclaveEncryptorType = enclaveEncryptorType;
}

public static PrivacyAccount create(
final URL privateKeyPath, final URL enclavePublicKeyPath, final URL enclavePrivateKeyPath) {
final URL privateKeyPath,
final URL enclavePublicKeyPath,
final URL enclavePrivateKeyPath,
final EnclaveEncryptorType enclaveEncryptorType) {
return new PrivacyAccount(
privateKeyPath, new URL[] {enclavePublicKeyPath}, new URL[] {enclavePrivateKeyPath});
privateKeyPath,
new URL[] {enclavePublicKeyPath},
new URL[] {enclavePrivateKeyPath},
enclaveEncryptorType);
}

public static PrivacyAccount create(
final URL privateKeyPath,
final URL[] enclavePublicKeyPath,
final URL[] enclavePrivateKeyPath) {
return new PrivacyAccount(privateKeyPath, enclavePublicKeyPath, enclavePrivateKeyPath);
final URL[] enclavePrivateKeyPath,
final EnclaveEncryptorType enclaveEncryptorType) {
return new PrivacyAccount(
privateKeyPath, enclavePublicKeyPath, enclavePrivateKeyPath, enclaveEncryptorType);
}

public String getPrivateKeyPath() {
Expand All @@ -62,6 +75,10 @@ public String[] getEnclavePrivateKeyPaths() {
.toArray(String[]::new);
}

public EnclaveEncryptorType getEnclaveEncryptorType() {
return enclaveEncryptorType;
}

private String toStringResource(final URL path) {
return path.getPath().substring(path.getPath().lastIndexOf(File.separator) + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,88 @@
*/
package org.hyperledger.besu.tests.acceptance.dsl.privacy.account;

import org.hyperledger.enclave.testutil.EnclaveEncryptorType;

import java.net.URL;

/** Supplier of known funded accounts defined in dev.json */
public class PrivacyAccountResolver {

public static final PrivacyAccount ALICE =
PrivacyAccount.create(
public enum PrivacyAccountResolver {
ALICE {
@Override
public PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType) {
return PrivacyAccount.create(
resolveResource("key"),
resolveResource("enclave_key_0.pub"),
resolveResource("enclave_key_0.key"));

public static final PrivacyAccount BOB =
PrivacyAccount.create(
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_0.pub")
: resolveResource("enclave_key_0.pub"),
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_0.key")
: resolveResource("enclave_key_0.key"),
enclaveEncryptorType);
}
},
BOB {
@Override
public PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType) {
return PrivacyAccount.create(
resolveResource("key1"),
resolveResource("enclave_key_1.pub"),
resolveResource("enclave_key_1.key"));

public static final PrivacyAccount CHARLIE =
PrivacyAccount.create(
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_1.pub")
: resolveResource("enclave_key_1.pub"),
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_1.key")
: resolveResource("enclave_key_1.key"),
enclaveEncryptorType);
}
},
CHARLIE {
@Override
public PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType) {
return PrivacyAccount.create(
resolveResource("key2"),
resolveResource("enclave_key_2.pub"),
resolveResource("enclave_key_2.key"));

public static final PrivacyAccount MULTI_TENANCY =
PrivacyAccount.create(
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_2.pub")
: resolveResource("enclave_key_2.pub"),
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_2.key")
: resolveResource("enclave_key_2.key"),
enclaveEncryptorType);
}
},
MULTI_TENANCY {
@Override
public PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType) {
return PrivacyAccount.create(
resolveResource("key"),
new URL[] {
resolveResource("enclave_key_0.pub"),
resolveResource("enclave_key_1.pub"),
resolveResource("enclave_key_2.pub")
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_0.pub")
: resolveResource("enclave_key_0.pub"),
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_1.pub")
: resolveResource("enclave_key_1.pub"),
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_2.pub")
: resolveResource("enclave_key_2.pub")
},
new URL[] {
resolveResource("enclave_key_0.key"),
resolveResource("enclave_key_1.key"),
resolveResource("enclave_key_2.key")
});

private static URL resolveResource(final String resource) {
return PrivacyAccountResolver.class.getClassLoader().getResource(resource);
}
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_0.key")
: resolveResource("enclave_key_0.key"),
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_1.key")
: resolveResource("enclave_key_1.key"),
enclaveEncryptorType.equals(EnclaveEncryptorType.EC)
? resolveResource("enclave_ec_key_2.key")
: resolveResource("enclave_key_2.key")
},
enclaveEncryptorType);
}
};

public PrivacyAccountResolver() {}
public abstract PrivacyAccount resolve(final EnclaveEncryptorType enclaveEncryptorType);

public PrivacyAccount resolve(final Integer account) {
switch (account) {
case 0:
return ALICE;
case 1:
return BOB;
case 2:
return CHARLIE;
default:
throw new RuntimeException("Unknown privacy account");
}
URL resolveResource(final String resource) {
return PrivacyAccountResolver.class.getClassLoader().getResource(resource);
}
}
Loading