Skip to content

activeledger/java-ecc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Activeledger

Activeledger - Java ECC SDK

The Activeledger Java ECC SDK has been built to provide an easy way to generate an ECC keypair that can be used to sign transactions to be sent to the Activeledger network.

Activeledger

Visit Activeledger.io

Read Activeledgers documentation

Installation

Usage

The SDK currently supports the following functions:

  • Generate a new ECC keypair
  • Sign a string using the generated private key

Generate a new ECC keypair

The generate method returns an array containing the public and private keys as HEX strings.

import io.activeledger.ALKeyPair;
import io.activeledger.KeyGenerator;

class MyClass {
    private void myMethod() {
        ALKeyPair pair;
        pair = this.generate();
        
        String prv, pub;
        prv = pair.getPrivate();
        pub = pair.getPublic();
        
        System.out.println("Private key HEX: " + prv + "\n");
        System.out.println("Public key HEX: " + pub + "\n");
    }
    
    private ALKeyPair generate() {
        KeyGenerator generator;
        generator = new KeyGenerator();
        
        ALKeyPair pair;
        pair = generator.generate();
        
        return pair;
    }
}

Sign a string using a private key

The sign method takes two parameters: the private key as a HEX string, and the data to be signed also as a string.

Note: The data must be JSON.

import io.activeledger.Signer;

class MyClass {
    private void getSignature(String privateKeyHex, String data) {
        Signer signer;
        signer = new Signer();
        
        String signature;
        signature = signer.sign(privateKeyHex, data);
        
        System.out.println("Signature: " + signature + "\n");
    }
}

License


This project is licensed under the MIT License

About

Minimal Java ECC Key gen and signing

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages