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));
}
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);
}
}
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");
}
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");
}
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();
}
Aggregations