No description
Find a file
2025-01-29 14:28:30 +01:00
lib added additional checks in ContractsSignTest 2025-01-27 15:28:13 +01:00
src moved ASAPCryptoUtilsExtension 2025-01-27 16:36:59 +01:00
.gitignore Initial commit 2024-12-09 09:22:58 +01:00
LICENSE.txt Add readme and license 2025-01-28 12:08:56 +01:00
pom.xml Use Java 8 for Android compatibility 2025-01-13 11:54:21 +01:00
README.md Updated links in the README 2025-01-29 14:28:30 +01:00

SharkContracts

This library uses ASAP and SharkPKI to realize digital contracts and signatures.

Usage

Examples for the usage of the library can be seen in the ContractsSignSimpleTest, ContractsSignTest or the sample android app.

The javadoc of SharkContracts explains the available methods in detail.

First, instantiate the component:

// Init ASAP/Shark Setup with SharkContracts
ASAPTestPeerFS asap = new ASAPTestPeerFS(name);
SharkPeer peer = new SharkTestPeerFS(name, name);

// Add PKI
SharkPKIComponentFactory certificateComponentFactory = new SharkPKIComponentFactory();
peer.addComponent(certificateComponentFactory, SharkPKIComponent.class);
SharkPKIComponent pki = (SharkPKIComponent) peer.getComponent(SharkPKIComponent.class);

// Add contracts
SharkContractsFactory contractsFactory = new SharkContractsFactory(pki, new TemporaryInMemoryStorage());
peer.addComponent(contractsFactory, SharkContracts.class);

// Start peer
peer.start(asap);

SharkContracts contracts = (SharkContracts) peer.getComponent(SharkContracts.class);

With the instance of SharkContracts, we can create and sign contracts. If you created a contract, it doesn't have to be signed.

// Create contract
byte[] testContent = "Hello world!".getBytes(StandardCharsets.UTF_8);
contracts.createContract(testContent, new ArrayList<>(), false);

// Sign contract
Contract incomingContract = ...;
contracts.signContract(contract);

Register for incoming contracts and signatures:

contracts.registerListener(new ContractsListener() {
    @Override
    public void onContractReceived(Contract contract) {
        // do something, e.g. sign it
        contracts.signContract(contract);
    }

    @Override
    public void onSignatureReceived(ContractSignature signature) {
        // handle signature
    }
});

Build jar

To build a jar, you can execute:

mvn package

The jar-file will be inside the target folder.

License

Copyright (c) 2025 Jannis Scheibe

This library is distributed under the LPGLv3.0. See the LICENSE.txt document for more information.