Skip to content

Contract class. #37

@Vineet77

Description

@Vineet77

Branch: contracts
Module: client

Implement the Contract class in Contract.java. The class is based off of the Contract struct in Project Aurum.

The Contract Class will have the following instance variables.

  • Version: An unsigned 16 bit integer.
  • Sender Public Key: This will be have a type of org.bouncycastle.crypto.params.ECPublicKeyParameters. Look at the Contract test to see an example.
  • Signature: an array of bytes
  • Recipient Public Key hash: an array of bytes.
  • Value: an unsigned 64 bit int (use java.math.BigInteger for this)
  • State nonce: an unsigned 64 bit int (once again use BigInteger for this)

All values must be valid (ex: version cannot be negative or exceed 2^16), so you will have to check these values and throw an IllegalArgumentException.

There should be the following getter functions:

BigInteger getValue(); 
BigInteger getStateNonce(); 
ECPublicKeyParameters getPublicKey();
byte[] getRecipientPublicKeyHash(); 
byte[] getSignature();
int getVersion(); 

The following setter functions:

setValue(String); 
setStateNonce(String);
setSignature(byte[])
setVersion(int)
setRecipientPublicKeyHash(byte[])
setPublicKey(ECPublicKeyParameters)

Also have the following function

boolean isSigned();

that returns true if signature is not null.

NOTE: Pass in strings for value and state nonce, so internally they can be passed into BigInteger. Look at

as an example.

All unit tests must pass (run .\gradlew test).

If you have any questions, don't be afraid to ask me.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions