Package freenet.crypt.ECDSA

Examples of freenet.crypt.ECDSA.Curves


   
    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
        Curves curve = ECDSA.Curves.P256;
        ECDSA ecdsa = new ECDSA(curve);
        String toSign = "test";
        byte[] signedBytes = toSign.getBytes("utf-8");
        //byte[] sig = ecdsa.sign(signedBytes);
        byte[] sig = ecdsa.signToNetworkFormat(signedBytes);
        System.out.println("Curve in use : " + curve.toString());
        System.out.println(ecdsa.getPublicKey().toString());
        System.out.println("ToSign   : "+toSign + " ("+toHex(signedBytes)+")");
        System.out.println("Signature: "+ toHex(sig));
        System.out.println("Verify?  : "+ecdsa.verify(sig, signedBytes));
       
        SimpleFieldSet sfs = ecdsa.asFieldSet(true);
        System.out.println("\nSerialized to: ");
        System.out.println(sfs.toString());
        System.out.println("Restored to: ");
        ECDSA ecdsa2 = new ECDSA(sfs.getSubset(curve.name()), curve);
        System.out.println(ecdsa2.getPublicKey());
        System.out.println("Verify?  : "+ecdsa2.verify(sig, signedBytes));
       
        System.out.println("Let's ensure that the signature always fits into "+ecdsa.curve.maxSigSize+" bytes.");
        int max = 0;
View Full Code Here

TOP

Related Classes of freenet.crypt.ECDSA.Curves

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.