Adds unrestricted privacy (#2324)

* Unrestricted Privacy: implement unrestricted privacy

- put data on chain
- wire up methods for sendRaw with restriction
- unrestricted pre-compile for processing transactions at Address.precompiled(PRIVACY - 4)
- store private state of unrestricted transactions
- route priv endpoints to unrestricted state resolution
- Implement unrestricted websocket endpoint
- Tidy up web3j transaction manager naming
- Parameterize tests for different privacy restrictions
- Implement our own PrivateTransactionManager
- remove chainId from sendRawTransaction calls
- Add check for member being a participant when creating privacy group
- refactor private marker transaction naming
- mark privacy-unrestricted-enabled as beta
- Remove create privacy group from unrestricted
- Unrestricted privacy acceptance tests will use a generated group id.
- rename enclavePublicKey to privacyUserId
- Ignore some tests for unrestricted privacy
- privacyGroupId has no significant meaning in unrestricted tests
- Change config label to be inline with previous conventions
- command tests to be added when made stable
Signed-off-by: Antony Denyer <git@antonydenyer.co.uk>
Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
Co-authored-by: Stefan Pingel <stefan.pingel@consensys.net>
This commit is contained in:
Antony Denyer
2021-06-29 07:22:08 +01:00
committed by GitHub
parent 5f2e79c8cb
commit 69223b8e75
135 changed files with 2827 additions and 1227 deletions

View File

@@ -16,5 +16,6 @@ package org.hyperledger.enclave.testutil;
public enum EnclaveType {
ORION,
TESSERA
TESSERA,
NOOP
}

View File

@@ -0,0 +1,104 @@
/*
* Copyright ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.enclave.testutil;
import static com.google.common.io.Files.readLines;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import com.google.common.base.Charsets;
import org.apache.tuweni.io.file.Files;
public class NoopEnclaveTestHarness implements EnclaveTestHarness {
private final Path tempDir;
private final EnclaveKeyConfiguration keyConfig;
public NoopEnclaveTestHarness(final Path tempDir, final EnclaveKeyConfiguration keyConfig) {
this.tempDir = tempDir;
this.keyConfig = keyConfig;
try {
copyKeys(keyConfig.getPrivKeyPaths());
copyKeys(keyConfig.getPubKeyPaths());
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
private void copyKeys(final String[] keys) throws IOException {
for (final String resource : keys) {
Files.copyResource(resource, tempDir.resolve(resource));
}
}
@Override
public void start() {}
@Override
public void stop() {}
@Override
public void close() {}
@Override
public List<Path> getPublicKeyPaths() {
return Arrays.stream(keyConfig.getPubKeyPaths())
.map(tempDir::resolve)
.collect(Collectors.toList());
}
@Override
public String getDefaultPublicKey() {
return getPublicKeys().get(0);
}
@Override
public List<String> getPublicKeys() {
return Arrays.stream(keyConfig.getPubKeyPaths())
.map(
x -> {
try {
return readLines(Path.of(tempDir.toString(), x).toFile(), Charsets.UTF_8).get(0);
} catch (IOException e) {
return e.getMessage();
}
})
.collect(Collectors.toList());
}
@Override
public URI clientUrl() {
return URI.create("http://noop:8080");
}
@Override
public URI nodeUrl() {
return URI.create("http://noop:8080");
}
@Override
public void addOtherNode(final URI otherNode) {}
@Override
public EnclaveType getEnclaveType() {
return EnclaveType.NOOP;
}
}