use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.
the class KeyUtil method generateWalletStandardECKey.
public static WalletKeyPair generateWalletStandardECKey() {
KeyPair key_pair = KeyUtil.generateECCompressedKey();
ByteString public_encoded = KeyUtil.getCompressedPublicKeyEncoding(key_pair.getPublic());
WalletKeyPair wkp = WalletKeyPair.newBuilder().setPublicKey(KeyUtil.getCompressedPublicKeyEncoding(key_pair.getPublic())).setPrivateKey(ByteString.copyFrom(key_pair.getPrivate().getEncoded())).setSignatureType(SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED).build();
return wkp;
}
use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.
the class KeyUtil method generateWalletDSAKey.
public static WalletKeyPair generateWalletDSAKey() {
try {
KeyPairGenerator key_gen = KeyPairGenerator.getInstance("DSA", Globals.getCryptoProviderName());
key_gen.initialize(3072);
KeyPair key_pair = key_gen.genKeyPair();
WalletKeyPair wkp = WalletKeyPair.newBuilder().setPublicKey(ByteString.copyFrom(key_pair.getPublic().getEncoded())).setPrivateKey(ByteString.copyFrom(key_pair.getPrivate().getEncoded())).setSignatureType(SignatureUtil.SIG_TYPE_DSA).build();
return wkp;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.
the class KeyUtil method generateWalletRSAKey.
public static WalletKeyPair generateWalletRSAKey(int key_len) {
try {
RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(key_len, RSAKeyGenParameterSpec.F4);
KeyPairGenerator key_gen = KeyPairGenerator.getInstance("RSA", Globals.getCryptoProviderName());
key_gen.initialize(spec);
KeyPair key_pair = key_gen.genKeyPair();
WalletKeyPair wkp = WalletKeyPair.newBuilder().setPublicKey(ByteString.copyFrom(key_pair.getPublic().getEncoded())).setPrivateKey(ByteString.copyFrom(key_pair.getPrivate().getEncoded())).setSignatureType(SignatureUtil.SIG_TYPE_RSA).build();
return wkp;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.
the class KeyUtil method generateWalletDSTU4145Key.
public static WalletKeyPair generateWalletDSTU4145Key(int curve) {
try {
ECGenParameterSpec spec = new ECGenParameterSpec("1.2.804.2.1.1.1.1.3.1.1.2." + curve);
KeyPairGenerator key_gen = KeyPairGenerator.getInstance("DSTU4145", Globals.getCryptoProviderName());
key_gen.initialize(spec);
KeyPair key_pair = key_gen.genKeyPair();
WalletKeyPair wkp = WalletKeyPair.newBuilder().setPublicKey(ByteString.copyFrom(key_pair.getPublic().getEncoded())).setPrivateKey(ByteString.copyFrom(key_pair.getPrivate().getEncoded())).setSignatureType(SignatureUtil.SIG_TYPE_DSTU4145).build();
return wkp;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of snowblossom.proto.WalletKeyPair in project snowblossom by snowblossomcoin.
the class CertGen method getServerSSLContext.
public static SslContext getServerSSLContext(WalletDatabase db) throws Exception {
if (db.getKeysCount() != 1)
throw new RuntimeException("Unexpected number of keys in wallet db");
if (db.getAddressesCount() != 1)
throw new RuntimeException("Unexpected number of addresses in wallet db");
WalletKeyPair wkp = db.getKeys(0);
AddressSpec address_spec = db.getAddresses(0);
WalletKeyPair tls_wkp = KeyUtil.generateWalletRSAKey(2048);
KeyPair tls_pair = KeyUtil.decodeKeypair(tls_wkp);
X509Certificate cert = generateSelfSignedCert(wkp, tls_wkp, address_spec);
// System.out.println(cert);
ByteString pem_cert = pemCodeCert(cert);
ByteString pem_prv = pemCodeECPrivateKey(tls_pair.getPrivate());
return GrpcSslContexts.forServer(pem_cert.newInput(), pem_prv.newInput()).build();
}
Aggregations