public void SignRawTransaction_GivenUnsignedTx_ReturnsCorrectlySignedTx() { var unsignedHexTx = "010000000198c61f42bf153b869557f9dcb5b95da114b6267ed3d17d7dffddb8ee7cb2ec080100000000" + "ffffffff02a08601000000000000001976a9146e0ece55286e20b787c47c69b528ed86c7de315588acc0" + "08ff050000000000001976a9146e0ece55286e20b787c47c69b528ed86c7de315588ac000000000000000" + "001001602060000000070fd0300010000001976a9146e0ece55286e20b787c47c69b528ed86c7de315588" + "ac00000000"; var signedHexTx = "010000000198c61f42bf153b869557f9dcb5b95da114b6267ed3d17d7dffddb8ee7cb2ec080100000000" + "ffffffff02a08601000000000000001976a9146e0ece55286e20b787c47c69b528ed86c7de315588acc00" + "8ff050000000000001976a9146e0ece55286e20b787c47c69b528ed86c7de315588ac0000000000000000" + "01001602060000000070fd0300010000006b483045022100f05de47bdaf5ec113716735e847b466e26c7d" + "fc86db1e3057c4d660fefac1f8e02202ecf1ad50c07c249c6b1f1bca06cfc5b91354bf51e8a344712e0c0" + "0277d47c4701210230293c8e9447ff8179eded8541a4079dc11a7d2b67742179e31648e2d7256a95"; var network = Network.Testnet; var securityService = new SecurityService(); var signingWallet = new SigningWallet(network, securityService); var signingService = new SigningService(signingWallet); var result = signingService.SignRawTransaction(_keys, HexUtil.ToByteArray(unsignedHexTx)); Assert.Equal(signedHexTx, result); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <DataContext>(x => x.UseSqlite(Configuration.GetConnectionString("DefaultConnection"))); services.AddControllers() // required in 3.0+ .AddNewtonsoftJson(options => { options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); services.AddCors(); services.Configure <PhotoUploadSettings>(Configuration.GetSection("PhotoUploadSettings")); services.AddAutoMapper(typeof(DataContext).Assembly); services.AddScoped <IAuthRepository, AuthRepository>(); services.AddScoped <IUserRepository, UserRepository>(); services.AddScoped <IPhotoRepository, PhotoRepository>(); services.AddScoped <IPhotoUploadService, CloudinaryService>(); var signingService = new SigningService(Configuration); services.AddSingleton <ISigningService>(signingService); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, ValidateIssuer = false, ValidateAudience = false, IssuerSigningKey = signingService.SecurityKey }; }); }
public static ConnectionDetails EncryptedToConnectionDetails( this IConfigurationSection ConnectionDetailSection, SigningService signingService) { return(new ConnectionDetails( signingService.Decrypt(ConnectionDetailSection[nameof(ConnectionDetails.DataSource)]), signingService.Decrypt(ConnectionDetailSection[nameof(ConnectionDetails.InitialCatalogue)]), signingService.Decrypt(ConnectionDetailSection[nameof(ConnectionDetails.UserId)]), signingService.Decrypt(ConnectionDetailSection[nameof(ConnectionDetails.Password)]) )); }
public static string ToEncryptedJson( ConnectionDetails connectionDetails, SigningService signingService) { return($@"""ConnectionDetails"": {{ ""DataSource"": ""{signingService.Encrypt(connectionDetails.DataSource)}"" ""InitialCatalogue"": ""{signingService.Encrypt(connectionDetails.InitialCatalogue)}"" ""UserId"": ""{signingService.Encrypt(connectionDetails.UserId)}"" ""Password"": ""{signingService.Encrypt(connectionDetails.Password)}"" }}"); }
public void SignRawTransaction_WithUnknownPrivateKey_ThrowsException() { var unsignedHexTx = "010000000198c61f42bf153b869557f9dcb5b95da114b6267ed3d17d7dffddb8ee7cb2ec080100000000" + "ffffffff02a08601000000000000001976a9146e0ece55286e20b787c47c69b528ed86c7de315588acc0" + "08ff050000000000001976a9146e0ece55286e20b787c47c69b528ed86c7de315588ac000000000000000" + "001001602060000000070fd0300010000001976a9146e0ece55286e20b787c47c69b528ed86c7de315588" + "ac00000000"; var network = Network.Testnet; var securityService = new SecurityService(); var signingWallet = new SigningWallet(network, securityService); var signingService = new SigningService(signingWallet); Assert.Throws <SigningException>(() => signingService.SignRawTransaction(new string[0], HexUtil.ToByteArray(unsignedHexTx)) ); }
protected override void ProcessRecord() { base.ProcessRecord(); try { var sourcesToDestination = MapSourceToDestination(GetFiles()); var signer = new SigningService(Credential.UserName, Credential.Password.ToUnsecureString(), sourcesToDestination, ServiceUrl, MessageHandler, ProgressHandler); signer.Sign(StrongName); } catch (AggregateException ae) { this.WriteErrorsAndThrowOnLast( ae.Flatten().InnerExceptions.Select(LazyCreateError)); } catch (Exception e) { ThrowTerminatingError(LazyCreateError(e)); } }
public override bool Execute() { try { //can we run Execute twice? I don't know so we'll say reset the CTS here _source = new CancellationTokenSource(); SetCredentials(); var sourcesToDestination = MapSourcesToDestination().ToArray(); Log.LogMessage(sourcesToDestination.First().Destination.FullName); var signer = new SigningService(UserName, Password, sourcesToDestination, ServiceUrl, MessageHandler, ProgressHandler); signer.Sign(StrongName, _source); } catch (Exception e) { Log.LogErrorFromException(e, true, true, null); } return(!Log.HasLoggedErrors); }
public void SignCoinstakeTransactions() { // Arrange // Delete previous wallet and create a new one, mine blocks. File.Delete(this.walletName.GetX1WalletFilepath(this.factory.Network, this.factory.DataFolder)); this.factory.WalletManagerFactory.CreateWallet(new WalletCreateRequest { Passphrase = this.passphrase, WalletName = this.walletName }); int blockMined = 200; long totalMiningReward = 0; for (var i = 0; i < blockMined; i++) { var transactions = new List <Transaction>(); var zeroOneTwo = i % 3; var addressType = zeroOneTwo == 0 ? AddressType.PubKeyHash : zeroOneTwo == 1 ? AddressType.ColdStakingHot : AddressType.MultiSig; transactions.Add(Create_Wallet.CreateCoinbase(this.factory.ChainIndexer.Tip.Height, this.factory.GetScriptPubKeyForMining(walletName, addressType), this.factory, out var reward)); totalMiningReward += reward; ChainedHeaderBlock nextBlock = this.factory.AddNextBlock(transactions); } this.factory.SetIBD(false); this.factory.SyncToHeight(blockMined, this.walletName); var wm = this.factory.WalletManagerFactory.AutoLoad2(this.walletName); // Act // *** Sign PubKeyHash output var budget = wm.GetBalance(null, AddressType.PubKeyHash); var kernelCoin = budget.StakingCoins.First().Value; var txPubKeyHash1 = CoinstakeTransactionService.CreateCoinstakeTransaction(kernelCoin, Money.Coins(50).Satoshi, this.date, this.passphrase, out var privateKey1); var txPubKeyHash2 = txPubKeyHash1.Clone(); Assert2.TransactionsEqual(txPubKeyHash1, txPubKeyHash2); // sign with TransactionBuilder txPubKeyHash1.Sign(C.Network, new[] { privateKey1 }, new ICoin[] { kernelCoin.ToCoin() }); // sign with SigningService SigningService.SignInputs(txPubKeyHash2, new[] { privateKey1 }, new[] { kernelCoin }); // same valid result? Assert2.IsSegWit(txPubKeyHash1); Assert2.TransactionsEqual(txPubKeyHash1, txPubKeyHash2); // *** Sign ColdStakingHot output var coldStakeKernelCoin = wm.GetBalance(null, AddressType.ColdStakingHot).StakingCoins.First().Value; var txColdStaking1 = CoinstakeTransactionService.CreateCoinstakeTransaction(coldStakeKernelCoin, Money.Coins(50).Satoshi, this.date, this.passphrase, out var privateKey2); var txColdStaking2 = txColdStaking1.Clone(); Assert2.TransactionsEqual(txColdStaking1, txColdStaking2); // sign with TransactionBuilder SignScriptAddress(txColdStaking1, privateKey2, coldStakeKernelCoin); Assert2.IsSegWit(txColdStaking1); // sign with SigningService SigningService.SignInputs(txColdStaking2, new[] { privateKey2 }, new [] { coldStakeKernelCoin }); // same valid result? Assert2.TransactionsEqual(txColdStaking1, txColdStaking2); // *** Sign MultiSig output var multiSigKernelCoin = wm.GetBalance(null, AddressType.MultiSig).StakingCoins.First().Value; var txMulti1 = CoinstakeTransactionService.CreateCoinstakeTransaction(multiSigKernelCoin, Money.Coins(50).Satoshi, this.date, this.passphrase, out var privateKey3); var txMulti2 = txMulti1.Clone(); // sign with TransactionBuilder SignScriptAddress(txMulti1, privateKey3, multiSigKernelCoin); Assert2.IsSegWit(txMulti1); // sign with SigningService SigningService.SignInputs(txMulti2, new[] { privateKey3 }, new[] { multiSigKernelCoin }); // same valid result? Assert2.TransactionsEqual(txMulti1, txMulti2); }
public EncryptionService(SigningService signingService) { this.signingService = signingService; }
public SigningRequestController( SigningService signingService) { _signingService = signingService; }
public SigningController(SigningService identityService) { _signingService = identityService; }