Search in sources :

Example 1 with WalletKeyPair

use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.

the class SeedTest method testKeyPair.

private static void testKeyPair(WalletKeyPair wkp, String name) throws Exception {
    WalletKeyPair ref = KeyUtil.generateWalletStandardECKey();
    logger.info(String.format("Reference key pub %d priv %d", ref.getPublicKey().size(), ref.getPrivateKey().size()));
    logger.info(String.format("testwkp key pub %d priv %d", wkp.getPublicKey().size(), wkp.getPrivateKey().size()));
    Random rnd = new Random();
    byte[] b = new byte[Globals.BLOCKCHAIN_HASH_LEN];
    rnd.nextBytes(b);
    ChainHash hash = new ChainHash(b);
    ByteString sig = SignatureUtil.sign(wkp, hash);
    SigSpec sig_spec = SigSpec.newBuilder().setSignatureType(wkp.getSignatureType()).setPublicKey(wkp.getPublicKey()).build();
    logger.info(String.format("Key report %s Pub size: %d, sig %d", name, wkp.getPublicKey().size(), sig.size()));
    Assert.assertTrue(SignatureUtil.checkSignature(sig_spec, hash.getBytes(), sig));
}
Also used : WalletKeyPair(snowblossom.proto.WalletKeyPair) Random(java.util.Random) ByteString(com.google.protobuf.ByteString)

Example 2 with WalletKeyPair

use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.

the class KeyUtilTest method testAllowedCurves.

@Test
public void testAllowedCurves() throws Exception {
    for (String curve : SignatureUtil.ALLOWED_ECDSA_CURVES) {
        WalletKeyPair wkp = KeyUtil.generateWalletECKey(curve);
        testKeyPair(wkp, curve);
    }
}
Also used : WalletKeyPair(snowblossom.proto.WalletKeyPair) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with WalletKeyPair

use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.

the class KeyUtilTest method testStandardWallet.

@Test
public void testStandardWallet() throws Exception {
    WalletKeyPair wkp = KeyUtil.generateWalletStandardECKey();
    testKeyPair(wkp, "standard");
}
Also used : WalletKeyPair(snowblossom.proto.WalletKeyPair) Test(org.junit.Test)

Example 4 with WalletKeyPair

use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.

the class KeyUtilTest method testDSA.

@Test
public void testDSA() throws Exception {
    logger.info("Generating DSA");
    WalletKeyPair wkp = KeyUtil.generateWalletDSAKey();
    logger.info(KeyUtil.decomposeASN1Encoded(wkp.getPublicKey()));
    testKeyPair(wkp, "DSA");
}
Also used : WalletKeyPair(snowblossom.proto.WalletKeyPair) Test(org.junit.Test)

Example 5 with WalletKeyPair

use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.

the class AddressUtil method getMultiSig.

public static AddressSpec getMultiSig(int required, List<WalletKeyPair> wkp_list) {
    AddressSpec.Builder addrspec = AddressSpec.newBuilder();
    addrspec.setRequiredSigners(required);
    Assert.assertTrue(required >= wkp_list.size());
    for (WalletKeyPair wkp : wkp_list) {
        addrspec.addSigSpecs(SigSpec.newBuilder().setSignatureType(wkp.getSignatureType()).setPublicKey(wkp.getPublicKey()).build());
    }
    return addrspec.build();
}
Also used : WalletKeyPair(snowblossom.proto.WalletKeyPair) AddressSpec(snowblossom.proto.AddressSpec)

Aggregations

WalletKeyPair (snowblossom.proto.WalletKeyPair)19 ByteString (com.google.protobuf.ByteString)9 Test (org.junit.Test)8 KeyPair (java.security.KeyPair)2 ECGenParameterSpec (java.security.spec.ECGenParameterSpec)2 RSAKeyGenParameterSpec (java.security.spec.RSAKeyGenParameterSpec)2 AddressSpec (snowblossom.proto.AddressSpec)2 X509Certificate (java.security.cert.X509Certificate)1 ECParameterSpec (java.security.spec.ECParameterSpec)1 PKCS8EncodedKeySpec (java.security.spec.PKCS8EncodedKeySpec)1 X509EncodedKeySpec (java.security.spec.X509EncodedKeySpec)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 Cipher (javax.crypto.Cipher)1 ChildNumber (org.bitcoinj.crypto.ChildNumber)1 DeterministicHierarchy (org.bitcoinj.crypto.DeterministicHierarchy)1 DeterministicKey (org.bitcoinj.crypto.DeterministicKey)1